[darcs-users] darcs patch: Replace single-use option with an argument (darcs help...
Eric Kow
kowey at darcs.net
Fri May 1 13:58:20 UTC 2009
On Fri, May 01, 2009 at 20:38:42 +1000, Trent W.Buck wrote:
> This replaces the "darcs help --match" option with "darcs help
> patterns", because --match isn't really being used as an option -- if
> it's present, the behaviour of darcs help is completely different (it
> ignores all arguments, for a start). And throwing away an option is
> generally good, because (as you can see) it shrinks the code a little
> bit in several icky "huge list of all options" places.
>
> One downside of this approach (already started with "darcs help
> manpage") is that the X in "darcs help X" is fought over between
> general help topics, and Darcs commands. If this worries people, we
> could relegate all the non-command help to an "on" subtree. That way
> we are safe as long as we never introduce a command "darcs on":
I don't have an opinion on the matter, and would be happy to apply this.
The patch itself looks fine at a cursory glance (and indeed looks like a
simplification).
I assume nobody else has objections.
> cmd_help _ ["on",topic] = ... -- manpage, patterns, environment &c
> cmd_help _ (cmd:args) = ... -- get, pull, push &c
This may also give us "permission" to add a whole lot of different
help topics, which may or may not be a good thing (redundancy?).
I'll bet we could pull it off in a way that avoids duplication
between the help text and the manual.
Replace single-use option with an argument (darcs help patterns).
-----------------------------------------------------------------
> Trent W. Buck <trentbuck at gmail.com>**20090501084159
> Ignore-this: ab3690bd88212a18962f1329e08e1497
> ] hunk ./src/Darcs/Arguments.lhs 32
> fixSubPaths, areFileArgs,
> DarcsOption( .. ), option_from_darcsoption,
> help, list_options, list_files,
> - help_on_match,
> any_verbosity, disable, restrict_paths,
> notest, test, working_repo_dir,
> testByDefault,
> hunk ./src/Darcs/Arguments.lhs 144
> getContent ListOptions = NoContent
> getContent Test = NoContent
> getContent NoTest = NoContent
> -getContent HelpOnMatch = NoContent
> getContent OnlyChangesToFiles = NoContent
> getContent LeaveTestDir = NoContent
> getContent NoLeaveTestDir = NoContent
> hunk ./src/Darcs/Arguments.lhs 478
> unified, summary, uncompress_nocompress, subject, in_reply_to,
> nocompress, match_several_or_range, match_several_or_last,
> author, askdeps, lookforadds, ignoretimes, test, notest, help, force_replace,
> - help_on_match, allow_unrelated_repos,
> + allow_unrelated_repos,
> match_one, match_range, match_several, fancy_move_add, sendmail_cmd,
> logfile, rmlogfile, leave_test_dir, from_opt, set_default
>
> hunk ./src/Darcs/Arguments.lhs 506
> \begin{code}
> help = DarcsNoArgOption ['h'] ["help"] Help
> "shows brief description of command and its arguments"
> -
> -help_on_match = DarcsNoArgOption [] ["match"] HelpOnMatch
> - "shows a summary of how to use patch matching rules"
> \end{code}
>
> \begin{options}
> hunk ./src/Darcs/Commands.lhs 192
> "Use 'darcs COMMAND --help' for help on a single command.\n" ++
> "Use 'darcs --version' to see the darcs version number.\n" ++
> "Use 'darcs --exact-version' to get the exact version of this darcs instance.\n" ++
> - "Use 'darcs help --match' for help on patch matching.\n\n" ++
> + "Use 'darcs help patterns' for help on patch matching.\n\n" ++
> "Check bug reports at http://bugs.darcs.net/\n"
>
> subusage :: DarcsCommand -> String
> hunk ./src/Darcs/Commands/Help.lhs 33
> get_command_help, extract_commands,
> nodefaults,
> usage )
> -import Darcs.Arguments ( DarcsFlag(..), help_on_match )
> +import Darcs.Arguments ( DarcsFlag(..) )
> import Darcs.External ( viewDoc )
> import Darcs.Manpage ( manpage )
> import Darcs.Patch.Match ( helpOnMatchers )
> hunk ./src/Darcs/Commands/Help.lhs 40
> import Darcs.Utils ( withCurrentDirectory )
> import Printer ( text )
> import Workaround ( getCurrentDirectory )
> +
> import qualified Darcs.TheCommands as TheCommands
>
> help_description :: String
> hunk ./src/Darcs/Commands/Help.lhs 58
> command_description = help_description,
> command_extra_args = -1,
> command_extra_arg_help = ["[<DARCS_COMMAND> [DARCS_SUBCOMMAND]] "],
> - command_command = help_cmd,
> + command_command = \ x y -> help_cmd x y >> exitWith ExitSuccess,
> command_prereq = \_ -> return $ Right (),
> command_get_arg_possibilities = return [],
> command_argdefaults = nodefaults,
> hunk ./src/Darcs/Commands/Help.lhs 63
> command_advanced_options = [],
> - command_basic_options = [help_on_match]}
> + command_basic_options = []}
>
> help_cmd :: [DarcsFlag] -> [String] -> IO ()
> hunk ./src/Darcs/Commands/Help.lhs 66
> -help_cmd _ ["manpage"] = do
> - putStr manpage
> - exitWith ExitSuccess
> -help_cmd opts [] =
> - do viewDoc $ text $
> - case () of _ | HelpOnMatch `elem` opts -> helpOnMatchers
> - | otherwise -> usage command_control_list
> - exitWith $ ExitSuccess
> +help_cmd _ ["manpage"] = putStr manpage
> +help_cmd _ ["patterns"] = viewDoc $ text $ helpOnMatchers
> +help_cmd _ [] = viewDoc $ text $ usage command_control_list
>
> help_cmd _ (cmd:args) =
> hunk ./src/Darcs/Commands/Help.lhs 71
> - do let disambiguated = disambiguate_commands command_control_list cmd args
> - case disambiguated of
> - Left err -> fail err
> + let disambiguated = disambiguate_commands command_control_list cmd args
> + in case disambiguated of
> + Left err -> fail err
> Right (cmds,_) ->
> hunk ./src/Darcs/Commands/Help.lhs 75
> - let msg = case cmds of
> - CommandOnly c -> get_command_help Nothing c
> - SuperCommandOnly c -> get_command_help Nothing c
> - SuperCommandSub c s -> get_command_help (Just c) s
> - in viewDoc $ text msg
> - exitWith $ ExitSuccess
> + let msg = case cmds of
> + CommandOnly c -> get_command_help Nothing c
> + SuperCommandOnly c -> get_command_help Nothing c
> + SuperCommandSub c s -> get_command_help (Just c) s
> + in viewDoc $ text msg
>
> list_available_commands :: IO ()
> list_available_commands =
> hunk ./src/Darcs/Flags.hs 27
> -- | The 'DarcsFlag' type is a list of all flags that can ever be
> -- passed to darcs, or to one of its commands.
> data DarcsFlag = Help | ListOptions | NoTest | Test
> - | HelpOnMatch | OnlyChangesToFiles
> + | OnlyChangesToFiles
> | LeaveTestDir | NoLeaveTestDir
> | Timings | Debug | DebugVerbose | DebugHTTP
> | Verbose | NormalVerbosity | Quiet
>
--
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090501/ba4ecfcd/attachment.pgp>
More information about the darcs-users
mailing list