File: darcsman.hs

package info (click to toggle)
darcs 1.0.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,796 kB
  • ctags: 321
  • sloc: haskell: 14,370; sh: 941; ansic: 893; perl: 810; makefile: 49; xml: 14
file content (86 lines) | stat: -rw-r--r-- 3,010 bytes parent folder | download
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
-- Copyright (C) 2003 David Roundy
--
-- 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, 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 Main (main) where

import Autoconf ( datadir )
import DarcsCommands
import TheCommands
import Time

main :: IO ()
main = man the_commands

man :: [DarcsCommand] -> IO ()
man cs = do man_header
            unorganized <- man_organizer cs
            putStrLn ".SH OTHER COMMANDS"
            man_helper unorganized
            man_trailer

man_organizer :: [DarcsCommand] -> IO [DarcsCommand]
man_organizer commands = mo commands
                         [("CREATING REPOSITORIES",
                           ["initialize","get"]),
                          ("MODIFYING REPOSITORY CONTENTS",
                           ["add","remove","mv","replace"]),
                          ("WORKING WITH CHANGES",
                           ["record","pull","push","send","apply"]),
                          ("SEEING WHAT YOU'VE DONE",
                           ["whatsnew","changes"])
                         ]
    where mo :: [DarcsCommand] -> [(String,[String])] -> IO [DarcsCommand]
          mo cs [] = return cs
          mo cs ((t,a):xs) =
              do putStrLn $ ".SH " ++ t
                 man_helper $ filter ((`elem` a) . command_name) cs
                 mo (filter (not . (`elem` a) . command_name) cs) xs

man_helper :: [DarcsCommand] -> IO ()
man_helper [] = return ()
man_helper (c:cs) = do
  putStrLn $ ".TP"
  putStrLn $ ".B "++command_name c
  putStrLn $ command_help c
  man_helper cs

man_trailer :: IO ()
man_trailer = do putStrLn ""
                 putStrLn ".SH AUTHOR"
                 putStrLn "David Roundy <droundy@abridgegame.org>."

man_header :: IO ()
man_header = do
  putStr ".TH DARCS \"1\" \""
  cl <- getClockTime
  ct <- toCalendarTime cl
  putStr $ show (ctMonth ct) ++ " " ++ show (ctYear ct)
  putStr "\" \"darcs\" \"User Commands\"\n"
  putStr $
   ".SH NAME\n"++
   "darcs \\- an advanced revision control system\n"++
   ".SH SYNOPSIS\n"++
   ".B darcs\n"++
   "\\fICOMMAND \\fR...\n"++
   ".SH DESCRIPTION\n"++
   "\n"++
   "darcs is a nifty revision control tool.  For more a detailed description,\n"++
   "see the html documentation, which should be available at\n"++
   datadir++"/doc/darcs/manual/index.html.  To easily get more specific help\n"++
   "on each command, you can call `darcs COMMAND --help'\n"++
   "\n"