-- Copyright: 2009 Dino Morelli
-- License: BSD3 (see LICENSE)
-- Author: Dino Morelli <dino@ui3.info>

module Multiplicity.Docs
   ( usage
   , sampleConfig
   )
   where

import System.Exit ( exitWith )

import Multiplicity.Common ( ecTerminated )
import Paths_multiplicity


{- Show usage to user and get out of here.
-}
usage :: IO ()
usage = do
   putStr $ unlines
      [ "Wrapper program for duplicity, adding config files"
      , ""
      , "Usage:"
      , "  multiplicity CONFPATH [ACTION] [ARGS for duplicity]"
      , "  multiplicity --sample-config"
      , ""
      , "Options:"
      , "  CONFPATH         Path to a multiplicity config file"
      , "  ACTION           duplicity action to perform"
      , "                   (defaults to full or incr as necessary)"
      , "  ARGS             Additional arguments for duplicity"
      , "  --sample-config  Print a sample config file to stdout"
      , ""
      , "Multiplicity is a configuration file driven wrapper around duplicity. It allows you to easily define backup sets as config files and avoid long, repetitive command lines."
      , ""
      , "Commands like this:"
      , ""
      , "  $ PASSPHRASE=\"foo bar baz\" duplicity --ssh-options -oIdentityFile=/home/foo/.ssh/bar --encrypt-key ABCDEF12 --include /var/log/baz --exclude /var/log --verbosity 5 full /var/log scp://foo@florb//var/remote/backup/location"
      , ""
      , "Turn into this, with multiplicity:"
      , ""
      , "  $ multiplicity yourbackup.conf full --verbosity 5"
      , ""
      , "Easy!"
      , ""
      , "For more information see the man page for duplicity, which you will need to have installed on your system in addition to multiplicity."
      , "And make sure you read the sample config file (use --sample-config), it's heavily documented."
      , ""
      , "Version 0.1.0  2009-Feb-05  Dino Morelli <dino@ui3.info>"
      , "http://ui3.info/d/proj/multiplicity.html"
      ]

   exitWith ecTerminated


{- Show sample config to user and get out of here.
-}
sampleConfig :: IO ()
sampleConfig = do
   confPath <- getDataFileName "conf/example.mult-conf"
   putStr =<< readFile confPath

   exitWith ecTerminated

