Made committer details and time = author details and time
[git-darcs-import.git] / src / darcsman.hs
blobc7095be58e72a07d2d4d402dd00a10c2413fd0d9
1 -- Copyright (C) 2003 David Roundy
2 --
3 -- This program is free software; you can redistribute it and/or modify
4 -- it under the terms of the GNU General Public License as published by
5 -- the Free Software Foundation; either version 2, or (at your option)
6 -- any later version.
7 --
8 -- This program is distributed in the hope that it will be useful,
9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 -- GNU General Public License for more details.
13 -- You should have received a copy of the GNU General Public License
14 -- along with this program; if not, write to the Free Software Foundation,
15 -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 module Main (main) where
19 import Autoconf ( datadir )
20 import Darcs.Commands
21 import Darcs.TheCommands
22 import Time
24 main :: IO ()
25 main = man (extract_commands command_control_list)
27 man :: [DarcsCommand] -> IO ()
28 man cs = do man_header
29 unorganized <- man_organizer cs
30 putStrLn ".SH OTHER COMMANDS"
31 man_helper unorganized
32 man_trailer
34 man_organizer :: [DarcsCommand] -> IO [DarcsCommand]
35 man_organizer commands = mo commands
36 [("CREATING REPOSITORIES",
37 ["initialize","get"]),
38 ("MODIFYING REPOSITORY CONTENTS",
39 ["add","remove","mv","replace"]),
40 ("WORKING WITH CHANGES",
41 ["record","pull","push","send","apply"]),
42 ("SEEING WHAT YOU'VE DONE",
43 ["whatsnew","query"])
45 where mo :: [DarcsCommand] -> [(String,[String])] -> IO [DarcsCommand]
46 mo cs [] = return cs
47 mo cs ((t,a):xs) =
48 do putStrLn $ ".SH " ++ t
49 man_helper $ filter ((`elem` a) . command_name) cs
50 mo (filter (not . (`elem` a) . command_name) cs) xs
52 man_helper :: [DarcsCommand] -> IO ()
53 man_helper cmds =
54 helper' "" cmds
55 where helper' _ [] = return ()
56 helper' s (c@DarcsCommand { }:cs) = do
57 putStrLn $ ".TP"
58 putStrLn $ ".B "++ s ++ " " ++ command_name c
59 putStrLn $ command_help c
60 helper' s cs
61 helper' s (c@SuperCommand { }:cs) = do
62 helper' (command_name c ++ " " ++ s)
63 (extract_commands (command_sub_commands c))
64 helper' s cs
66 man_trailer :: IO ()
67 man_trailer = do putStrLn ""
68 putStrLn ".SH BUGS"
69 putStrLn "Report bugs by mail to"
70 putStrLn ".B bugs@darcs.net"
71 putStrLn "or via the web site at"
72 putStrLn ".BR http://bugs.darcs.net/ ."
73 putStrLn ""
74 putStrLn ".SH AUTHOR"
75 putStrLn "David Roundy <droundy@abridgegame.org>."
77 man_header :: IO ()
78 man_header = do
79 putStr ".TH DARCS \"1\" \""
80 cl <- getClockTime
81 ct <- toCalendarTime cl
82 putStr $ show (ctMonth ct) ++ " " ++ show (ctYear ct)
83 putStr "\" \"darcs\" \"User Commands\"\n"
84 putStr $
85 ".SH NAME\n"++
86 "darcs \\- an advanced revision control system\n"++
87 ".SH SYNOPSIS\n"++
88 ".B darcs\n"++
89 "\\fICOMMAND \\fR...\n"++
90 ".SH DESCRIPTION\n"++
91 "\n"++
92 "darcs is a nifty revision control tool. For more a detailed description,\n"++
93 "see the html documentation, which should be available at\n"++
94 datadir++"/doc/darcs/manual/index.html. To easily get more specific help\n"++
95 "on each command, you can call `darcs COMMAND --help'\n"++
96 "\n"