7O      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN0OPQRSTUVWXYZ[\]^_`GSet the group name for this option. The groups are used to section the I help output (the options of a given group are shown together, under the I heading of the group). The ordering of the groups is given by the first I flag of each group. Flags themselves are in the order in which they are ) given in the ADT or Record in question. GWhether the option is enabled. Disabled options are not recognized and J are not shown in help (effectively, they do not exist). Used to enable a G subset of all available options for a given command. For Record-based  commands (see  RecordCommand*), this is handled automatically based on  fields available in the command'*s constructor. Otherwise, constructs like  ? enable <% option1 +% option2 +% option3 %% disable <% option4 may be quite useful. &When this attribute is given, the flag's value will be passed to the ; provided IO action (which would presumably record the flag' s value in a G global IORef for later use). Like with Default, the attribute is only F effective if the parameter type of the provided function matches the A parameter type of the option to which the attribute is applied. HSet default value for this option. The default is only applied when its  type matches the option'+s parameter type, otherwise it is ignored. )Set the help string for an argument, the FOO in --wibblify=FOO. HWhen True, this option will require that the argument must be provided. I If the argument is also Positional, any preceeding Positional arguments  should also be Required. 6When set, this option will not show up on help and won't create a flag E (similar to Extra), but instead it will contain the n-th non-option J argument. The argument used up by such a positional option will not show ) up in the list of non-option arguments. EWhen True, this option will contain the list of non-option arguments 2 passed to the command. Only applicable to [String]-typed options. Options K marked extra will not show up in help and neither will they be recognized  by their name on commandline. ESet help string (one-line summary) for an option. Displayed in help. GWhether this option is invertible. Only applies to boolean options and L defaults to True. (Invertible means that for --foo, there are --no-foo and I --foo=no alternatives. A non-invertible option will only create --foo.) GSet a list of long flags for an inversion of the option. Only used for & boolean invertible options. See also long. (Set a list of long flags for an option. >Set a list of short flags (single character per flag, like in -c,  -h%) for an option. Without the leading -. Join attribute mappings. E.g. +Key1 %> Attr1 %+ Attr2 %% Key2 %> Attr3 %+  Attr4. Also possible is [ Key1 %> Attr1, Key2 %> Attr2 ] %% Key3 %>  Attr3, or many other variations. abcKCreate a group. This extracts all the keys that are (explicitly) mentioned K in the body of the group and assigns the corresponding Group attribute to  them. Normally used like this:  1 group "Group name" [ option %> Help "some help" : , another %> Help "some other help" ] -Do not let the type confuse you too much. :) For convenience. Same as Enabled True. For convenience. Same as Enabled False. For convenience. Same as Long [foo] %+ InvLong [no-foo] For convenience. Same as Short [x] GJoin multiple attributes into a list. Available for convenience (using  [Attribute]@ directly works just as well if preferred, although this is not  the case with keys, see +%). dIAttach a (list of) attributes to a key. The key is usually either an ADT  constructor (for use with ADTFlag(-style flags) or a record selector (for  use with  RecordFlags).  ; data RFlags = Flags { wibblify :: Int, simplify :: Bool } & data AFlag = Simplify | Wibblify Int @ rattr = wibblify %> Help "Add a wibblification pass." (%% ...) @ aattr = Wibblify %> Help "Add a wibblification pass." (%% ...) %++ can be used to chain multiple attributes:  S attrs = wibblify %> Help "some help" %+ Default (3 :: Int) %+ ArgHelp "intensity" But lists work just as fine: S attrs = wibblify %> [ Help "some help", Default (3 :: Int), ArgHelp "intensity" ] BAttach an attribute to multiple keys: written from right to left,  i.e.  Attribute <% Key1 +% Key2&. Useful for setting up option groups  (although using group1 may be more convenient in this case) and option  enablement. %Join multiple keys into a list, e.g.  Key1 +% Key2. Useful with <% to 5 list multiple (possibly heterogenously-typed) keys. Set an attribute on all keys. ;OPQRSTUVWXYZ[\]^_` aefghijklmnobcd0OPPQRRSUTTUVWWX[ZYYZ[\]^]^_``   abcd&pJControls how to display boolean options in help output: MergePrefix shows  --[no-]$foo, MergeSuffix shows --foo[=yes|no] and NoMerge shows two lines, H first with --foo and help, second with --no-foo (and no further help). qrstuvwxyz{|}~ GThe default parser for option arguments. Handles strings, string lists < (always produces single-element list), integers, booleans ( yes|true|1 vs   no|false|0), PathF and integer lists ( --foo=1,2,3). !GExtract a long option name from an ADT constructor using its name. For  Foo, you will get foo and on FooBar will get foo-bar. .pqrstuvwxyz{|}~ !&psrqqrst uvwxyz{|}~uvwxyz{|}~ !'"#$%2A class that describes a single (sub)command. The cmd type parameter is J just for dispatch (and the default command name is derived from this type's L name, but this can be overriden). It could be an empty data decl as far as L this library is concerned, although you may choose to store information in  it. 2To parse the commandline for a given command, see execute. The basic usage  can look something like this: 7 data Flag = Summary | Unified Bool | LookForAdds Bool  instance ADTFlag Flag   [...]  , data Whatsnew = Whatsnew deriving Typeable  , instance Command Whatsnew (ADT Flag) where ; options _ = enable <% Summary +% Unified +% LookForAdds 8 summary _ = "Create a patch from unrecorded changes."  ) run _ f opts = do putStrLn $ "Record." 5 putStrLn $ "Options: " ++ show f < putStrLn $ "Non-options: " ++ show opts &An  Attribute# mapping for flags provided by the flag type parameter. 'HSet this to True if the command is a supercommand (i.e. expects another G subcommand). Defaults to False. Supercommands can come with their own @ options, which need to appear between the supercommand and its 9 subcommand. Any later options go to the subcommand. The run (and   description&) method of a supercommand should use dispatch and   helpCommands3 respectively (on its list of subcommands) itself. ()How to process options for this command.  NoOptions disables option B processing completely and all arguments are passed in the [String]  parameter to run. Permuted( collects everything that looks like an L option (starts with a dash) and processes it. The non-option arguments are 1 filtered and passed to run like above. Finally,  NonPermuted only I processes options until a first non-option argument is encountered. The 2 remaining arguments are passed unchanged to run. )5The handler that actually runs the command. Gets the setup value as ( folded from the processed options (see Combine) and a list of non-option  arguments. *Provides the commands' short synopsis. +EProvides a short (one-line) description of the command. Used in help  output. ,-=The name of the command. Normally derived automatically from cmd, but  may be overriden. .A convenience  undefined of the command, for use with Commands. /0*How to process options for a command. See  optionStyle for details. 12346:This could be used to implement a disambiguation function Note that there isn')t presently a notion of hidden commands,  but we'9re taking them into account now for future API stability show hidden commands too 74Parse options for and execute a single command (see Command ). May be 4 useful for programs that do not need command-based dispatch , but still  make use of the Command' class to describe themselves. Handles --help G internally. You can use this as the entrypoint if your application is ) non-modal (i.e. it has no subcommands). 8(Chain commands into a list suitable for dispatch and  helpCommands. E.g.: 2 dispatch (Command1 %: Command2 %: Command3) opts 9fail ;<Given a list of commands (see %:') and a list of commandline arguments, B dispatch on the command name, parse the commandline options (see execute) I and transfer control to the command. This function also implements the  help pseudocommand. =Like <9 but with the ability to control what happens when there  is an error on user input eg. > >EHelper for dying with an error message (nicely, at least compared to  fail in IO). +"#$%&'()*+,-./0123456789:;<=>'"##$% &'()*+,-./&'()*+,-./032112346789;<=>?KThe ADT wrapper type allows use of classic ADTs (algebraic data types) for L flag representation. The flags are then passed to the command as a list of L values of this type. However, you need to make the type an instance of the M Attributes first (if you do not wish to attach any attributes, you may keep ! the instance body empty). E.g.:  % data Flag = Simplify | Wibblify Int  instance Attributes where \ attributes _ = Wibblify %> Help "Add a wibblification pass." %+ ArgHelp "intensity" %% E Simplify %> Help "Enable a two-pass simplifier." The Command instances should then use  (ADT Flag) for their second type  parameter (the flag type). ??@DA bridge that allows multi-constructor record types to be used as a L description of a command set. In such a type, each constructor corresponds J to a single command and its fields to its options. To describe a program  with two commands, foo and bar, each taking a --wibble boolean option  and bar also taking a --text= string option, you can write:  ( data Commands = Foo { wibble :: Bool } 8 | Bar { wibble :: Bool, text :: String }  - instance RecordCommand Commands where (...) You should at least implement run',  rec_options and  mode_summary are optional. Arun'< is your entrypoint into the whole set of commands. You can : dispatch on the command by looking at the constructor in cmd: P run' cmd@(Foo {}) _ = putStrLn $ "Foo running. Wibble = " ++ show (wibble cmd) / run' cmd@(Bar {}) _ = putStrLn "This is bar." BEYou can also provide extra per-command flag attributes (match on the  constructor like with run'-). The attributes shared by various commands  can be set in  rec_attrs in  Attributes instead. CISet the per-command option style, useful for supercommands to pass their : options through to another dispatch, by using NoOptions. DPattern match like in run'+ to identify any supercommands, which will > allow --help flags to be passed through to the sub-commands. EIProvide a summary help string for each mode. Used in help output. Again,  pattern match like in run'. F9Provide a help blurb for each mode. Use patterns like in run'. GIOptionally override the default usage string for each mode. Use patterns  like in run'. HKThis wrapper type allows use of record types (single or multi-constructor) L for handling flags. Each field of the record is made into a single flag of H the corresponding type. The record needs to be made an instance of the   Attributes: class. That way, attributes can be attached to the field 7 selectors, although when used with RecordCommand, its  rec_options method = can be used as well and the Attributes instance left empty.  : data Flags = Flags { wibblify :: Int, simplify :: Bool } ! instance Attributes Flags where  attributes _ = P wibblify %> Help "Add a wibblification pass." %+ ArgHelp "intensity" %% 9 simplify %> Help "Enable a two-pass simplifier." <A single value of the Flags type will then be passed to the Command  instances (those that use  Record Flags" as their second type parameter), H containing the value of the rightmost occurence for each of the flags. JTODO: List-based option types should be accumulated instead of overriden. IConstruct a command list (for dispatch/ helpCommands ) from a . multi-constructor record data type. See also  RecordCommand. Alternatively,  you can use  dispatchR directly. JJObtain a value that is an instance of Command, i.e. suitable for use with  defaultCommand and other Command-based APIs. GRecord field update using a string field name. Sets a field value in a - record, using a (string) name of the field, KA command parsing &' dispatch entry point for record-based  commands. Ex. (see  RecordCommand): 5 main = getArgs >>= dispatchR [] >>= \x -> case x of J Foo {} -> putStrLn $ "You asked for foo. Wibble = " ++ show (wibble x) 1 Bar {} -> putStrLn $ "You asked for bar. ..." LLike execute=, but you get the flags as a return value. This is useful to @ implement non-modal applications with record-based flags, eg.: 8 data Main = Main { greeting :: String, again :: Bool } # deriving (Typeable, Data, Eq) ) instance Attributes Main where -- (...)  instance RecordCommand Main 5 main = getArgs >>= executeR Main {} >>= \opts -> do & putStrLn (greeting opts) -- (...) @ABCDEFGHIJKL@ABCDEFGABCDEFGHIJKLNUse M8 specify an empty attribute set. Available since 0.3.2. Create a global setter//getter pair for a flag. The setter can be then  passed to the Global7 attribute and the getter used globally to query value  of that flag. Example: ) data Flag = Wibblify Int | Verbose Bool , (setVerbose, isVerbose) = globalFlag False   instance Attributes Flag where 1 attributes _ = Verbose %> Global setVerbose  9 putVerbose str = isVerbose >>= flip when (putStrLn str) O  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO ?HM89%&'()*+,-./<=754:;0321$6@ABCDEFGIKLJN !"#>N     !"#$%&'()*+,--./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiijklmnopqrstuvwxyz{|}~.IR cmdlib-0.3.5System.Console.CmdLibSystem.Console.CmdLib.AttributeSystem.Console.CmdLib.FlagSystem.Console.CmdLib.CommandSystem.Console.CmdLib.ADTsSystem.Console.CmdLib.Recordbase Data.DataDataData.Typeable.InternalTypeableSystem.EnvironmentgetArgs AttributeGroupEnabledGlobalDefaultArgHelpRequired PositionalExtraHelp InvertibleInvLongLongShort%%groupenabledisablesimplelongshort%+%><%+% everywhere Attributes attributesreadFlag readCommon<+< HelpCommand CommandWrapCommandoptions supercommand optionStylerunsynopsissummaryhelpcmdnamecmdcmd_flag_defaults OptionStyle NoOptions NonPermutedPermuted helpOptions helpCommands commandNamesexecute%: commandGroupnoHelpdefaultCommanddispatch dispatchOrdieADT RecordCommandrun' rec_optionsrec_optionStylerec_superCommand mode_summary mode_help mode_synopsisRecordrecordCommands recordCommand dispatchRexecuteR noAttributes globalFlagKeystoKeysToKeytoKeyKeyKeyFKeyC AttributeList toAttributes AttributeMapEmptyMap SingletonMap:%%AttributeMapLikeattrFunattrKeysRequiredArgExceptiongetattrdefvalue setglobalattrsenabledextralongsshortsinvlongs invertiblehelpattrarghelpgetgrouprequired positional HelpStyleNoMerge MergeSuffix MergePrefixFlagTypeFolded flag_attrkey flag_attrs flag_argsflag_set flag_parse flag_value flag_eval flag_type flag_list flag_defaults flag_fold flag_empty OptionType BadOptionRequiredArgumentOptionalArgument BooleanOption SimpleOptionPathF optionType usageDescrrequiredFlagStroptDescrflagToOptDescr helpDescrnameFromConstrdefaults nonoptionisExtra isPositional isRequiredformatOptDescrOptionsoptional hyphenate DispatchOptDefaultCommandNoHelp CommandGroupCommands toCommands cmdoptionscmdattrsexecute' findCommand dispatch' printHelp printCommandsImp RecordMode rec_cmdname rec_initialappendsetFieldgetField evalField