{"action":"created","issue":{"url":"https://api.github.com/repos/Gabriel439/Haskell-Turtle-Library/issues/10","labels_url":"https://api.github.com/repos/Gabriel439/Haskell-Turtle-Library/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/Gabriel439/Haskell-Turtle-Library/issues/10/comments","events_url":"https://api.github.com/repos/Gabriel439/Haskell-Turtle-Library/issues/10/events","html_url":"https://github.com/Gabriel439/Haskell-Turtle-Library/issues/10","id":56181226,"number":10,"title":"Full practical example","user":{"login":"codygman","id":225847,"avatar_url":"https://avatars.githubusercontent.com/u/225847?v=3","gravatar_id":"","url":"https://api.github.com/users/codygman","html_url":"https://github.com/codygman","followers_url":"https://api.github.com/users/codygman/followers","following_url":"https://api.github.com/users/codygman/following{/other_user}","gists_url":"https://api.github.com/users/codygman/gists{/gist_id}","starred_url":"https://api.github.com/users/codygman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codygman/subscriptions","organizations_url":"https://api.github.com/users/codygman/orgs","repos_url":"https://api.github.com/users/codygman/repos","events_url":"https://api.github.com/users/codygman/events{/privacy}","received_events_url":"https://api.github.com/users/codygman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-01T22:29:05Z","updated_at":"2015-02-02T00:08:56Z","closed_at":null,"body":"Nothing like a full example to pull all the concepts you just learned together. I give you this code so you can see review the code (and see what mistakes a new user of your library made) and to possibly include for others to learn from.\r\n\r\nI know some repositories have a examples subdirectory. This could even fit on a Tutorials.DatabaseBackup example documentation page or something?\r\n\r\ncode: \r\n\r\n```haskell\r\n{-# LANGUAGE OverloadedStrings #-}\r\nimport           Control.Category ((<<<), (>>>))\r\nimport qualified Control.Foldl    as Fold\r\nimport           Data.Maybe\r\nimport           Turtle\r\n\r\nrun sink f = sink (f empty)\r\n\r\nmain = do\r\n  -- backup old db\r\n  output \"revert.sql\" (inproc \"mysqldump\" [\"-uroot\", \"myproject\"] empty)\r\n\r\n  -- newest filename from server\r\n  newestFileName <- fmap fromText . listToMaybe <$>\r\n                    fold ((inproc \"ssh\" [\"lalala\", \"ls -Art /backups/db/myproject | tail -n 1\"]) empty) Fold.list\r\n  let serverName = \"lalala\"\r\n      dbName = \"myproject-copy\"\r\n      backupDir = \"/backups/db/myproject/\"\r\n      newestFileName' = fromMaybe (error \"couldn't get backup path\") newestFileName\r\n      backupFilePath = backupDir </> newestFileName'\r\n      localFilePath = \"/tmp/\" </> newestFileName'\r\n      backupFilePath' = either (\\e -> error $ \"Couldn't parse backupFilePath: \" <> show e) id (toText backupFilePath)\r\n      localFilePath' = either (\\e -> error $ \"Couldn't parse localFilePath: \" <> show e) id (toText localFilePath)\r\n\r\n  -- download backup\r\n  sh $ inproc \"rsync\" [\"-avz\", serverName, \":\", backupFilePath', localFilePath'] empty\r\n\r\n  -- drop old db (should have backup)\r\n  run sh (inshell (\"mysqladmin -uroot drop -f \" <> dbName))\r\n\r\n  -- restore database from just downloaded backup\r\n  run sh (inshell (\"zcat \" <> localFilePath') >>> inshell (\"mysql -uroot\" <> dbName))\r\n\r\n  print \"done\"\r\n```"},"comment":{"url":"https://api.github.com/repos/Gabriel439/Haskell-Turtle-Library/issues/comments/72392795","html_url":"https://github.com/Gabriel439/Haskell-Turtle-Library/issues/10#issuecomment-72392795","issue_url":"https://api.github.com/repos/Gabriel439/Haskell-Turtle-Library/issues/10","id":72392795,"user":{"login":"codygman","id":225847,"avatar_url":"https://avatars.githubusercontent.com/u/225847?v=3","gravatar_id":"","url":"https://api.github.com/users/codygman","html_url":"https://github.com/codygman","followers_url":"https://api.github.com/users/codygman/followers","following_url":"https://api.github.com/users/codygman/following{/other_user}","gists_url":"https://api.github.com/users/codygman/gists{/gist_id}","starred_url":"https://api.github.com/users/codygman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codygman/subscriptions","organizations_url":"https://api.github.com/users/codygman/orgs","repos_url":"https://api.github.com/users/codygman/repos","events_url":"https://api.github.com/users/codygman/events{/privacy}","received_events_url":"https://api.github.com/users/codygman/received_events","type":"User","site_admin":false},"created_at":"2015-02-02T00:08:56Z","updated_at":"2015-02-02T00:08:56Z","body":"I'd like to (and think it would be fun to) convert the linux steam install script that famously deleted someone’s entire root directory because of an uninitialized environmental variable.\r\n\r\nIt would also be good PR for Turtle and even the \"fiercest' pragmatists would acknowledge it solved a real world task. link if your curious:\r\n\r\nhttps://github.com/indrora/steam_latest/blob/master/scripts/steam.sh"}}