-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCommands.hs
102 lines (85 loc) · 3.2 KB
/
Commands.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{- hpodder component
Copyright (C) 2006-2007 John Goerzen <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
Module : Commands
Copyright : Copyright (C) 2006 John Goerzen
License : GNU GPL, version 2 or above
Maintainer : John Goerzen <[email protected]>
Stability : provisional
Portability: portable
Written by John Goerzen, jgoerzen\@complete.org
-}
module Commands where
import Data.List
import Text.Printf
import Utils
import Types
import Config
import Data.ConfigFile
import Data.Either.Utils
import qualified Commands.Add
import qualified Commands.Ls
import qualified Commands.Update
import qualified Commands.Download
import qualified Commands.Setup
import qualified Commands.Catchup
import qualified Commands.ImportIpodder
import qualified Commands.Rm
import qualified Commands.SetStatus
import qualified Commands.SetTitle
import qualified Commands.EnableDisable
--allCommands :: [(String, Command)]
allCommands =
[Commands.Add.cmd,
Commands.Catchup.cmd,
Commands.EnableDisable.cmd_disable,
Commands.Download.cmd,
Commands.EnableDisable.cmd_enable,
fetch,
Commands.ImportIpodder.cmd,
Commands.Ls.lscasts,
lscommands,
Commands.Ls.lsepisodes,
Commands.Ls.lseps,
Commands.Rm.cmd,
Commands.SetStatus.cmd,
Commands.SetTitle.cmd,
Commands.Update.cmd]
lscommands =
simpleCmd "lscommands" "Display a list of all available commands" ""
[] lscommands_worker
lscommands_worker _ _ =
do putStrLn "All available commands:"
printf "%-20s %s\n" "Name" "Description"
putStrLn "-------------------- -------------------------------------------------------"
mapM_ (\(_, x) -> printf "%-20s %s\n" (cmdname x) (cmddescrip x))
allCommands
fetch =
simpleCmd "fetch" "Scan feeds, then download new episodes" fetch_help
[] fetch_worker
fetch_worker gi ([], casts) =
do cp <- loadCP
let showintro = forceEither $ get cp "general" "showintro"
if showintro
then Commands.Setup.cmd_worker gi ([], [])
else do Commands.Update.cmd_worker gi ([], casts)
Commands.Download.cmd_worker gi ([], casts)
fetch_worker _ _ =
fail $ "Invalid arguments to fetch; please see hpodder fetch --help"
fetch_help = "Usage: hpodder fetch [castid [castid...]]\n\n" ++
genericIdHelp ++
"\nThe fetch command will cause hpodder to scan all feeds (as with\n\
\\"hpodder update\") and then download all new episodes (as with\n\
\\"hpodder download\").\n"