### Undecorated Arguments for Subcommands Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Demonstrates using undecorated arguments to create 'subcommands', like 'commit' in this example. ```shell foo commit -Am "Why are you reinventing git?" ``` -------------------------------- ### Defining Injected Signatures for Subcommands Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Example of defining injected signatures for a subcommand, allowing for nested argument parsing. ```objective-c XPMArgumentSignature * commitSubcommand = [XPMArgumentSignature argumentSignatureWithFormat:@"[commit]"]; [commitSubcommand setInjectedSignatures:[NSSet setWithObjects: [XPMArgumentSignature argumentSignatureWithFormat:@"[-A --all]"], [XPMArgumentSignature argumentSignatureWithFormat:@"[-m --commit-message]="], nil]]; ``` -------------------------------- ### Separating Value Lists with Double Dash Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Example of using a double dash ('--') as a value barrier to separate lists of values for different arguments. ```shell foo -ofv ouput1 output2 output3 -- input1 input2 input3 input4 ``` -------------------------------- ### Undecorated Arguments for Input/Output Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Shows how to use undecorated arguments for specifying input and output files, similar to the 'dd' utility. ```shell foo if=infile of=outfile ``` -------------------------------- ### Custom Help Descriptions for Flags Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Define custom help messages for command-line flags using `setDescriptionHelper`. This allows for more user-friendly and informative help output. ```Objective-C XPMArgumentSignature * verbose = [XPMArgumentSignature argumentSignatureWithFormat:@"[-v --verbose]"]; XPMArgumentSignature * help = [XPMArgumentSignature argumentSignatureWithFormat:@"[-h --help]"]; [verbose setDescriptionHelper:(NSString *)(^)(XPMArgumentSignature * currentSignature, NSUInteger indentLevel, NSUInteger terminalWidth) { return [@"-v --verbose Emit more information." xpmargs_mutableStringByIndentingToWidth:indentLevel * 2 lineLength:terminalWidth]; }]; [help setDescriptionHelper:(NSString *)(^)(XPMArgumentSignature * currentSignature, NSUInteger indentLevel, NSUInteger terminalWidth) { return [@"-h --help Show this message." xpmargs_mutableStringByIndentingToWidth:indentLevel * 2 lineLength:terminalWidth]; }]; XPMArgumentPackage * package = [[NSProcessInfo processInfo] xpmargs_parseArgumentsWithSignatures:[NSSet setWithObjects:verbose, help, nil]]; if ([package booleanValueOfFlag:help]) { struct winsize ws; ioctl(0, TIOCGWINSZ, &ws); printf("My Really Cool CLI Tool v0.1\n\n"); printf("%s\n", [[verbose descriptionForHelpWithIndent:2 width:ws.ws_col] UTF8String]); printf("%s\n", [[help descriptionForHelpWithIndent:2 width:ws.ws_col] UTF8String]); printf("\n(C) 2012 by Your Face. All your base are belong to us.\n"); } ``` -------------------------------- ### Handling Value Barriers with Multiple Arguments Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Demonstrates how value barriers (like '--' or another argument) separate lists of values when multiple arguments accept multiple values. ```objective-c XPMArgumentSignature *inFiles = [XPMArgumentSignature argumentSignatureWithFormat:@"[-f --input-files]={1,5}"], *outputFiles = [XPMArgumentSignature argumentSignatureWithFormat:@"[-o --output-files]={1,5}"]; ``` -------------------------------- ### Defining Argument Signature with Value Range Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Shows how to define an argument signature that accepts a range of values (1 to 5) per invocation. ```objective-c XPMArgumentSignature * files = [XPMArgumentSignature argumentSignatureWithFormat:@"[-f --files]={1,5}"]; ``` -------------------------------- ### Separating Value Lists with Argument Invocation Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Illustrates using another argument invocation (e.g., '-v') as a value barrier to separate lists of values. ```shell foo -of ouput1 output2 output3 -v input1 input2 input3 input4 ``` -------------------------------- ### Basic Argument Parsing Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Defines argument signatures and parses them using XPMArgumentParser. Checks for boolean flags and specific argument values. ```objective-c XPMArgumentSignature * force = [XPMArgumentSignature argumentSignatureWithFormat:@"[-f --force]"], * soft = [XPMArgumentSignature argumentSignatureWithFormat:@"[-s --soft]"], * outputFile = [XPMArgumentSignature argumentSignatureWithFormat:@"[-o --output-file of]=", * inputFile = [XPMArgumentSignature argumentSignatureWithFormat:@"[-i --input-file if]={1,}"]; NSArray * signatures = @[force, soft, outputFile, inputFile]; XPMArgumentPackage * package = [[NSProcessInfo currentProcess] xpmargs_parseArgumentsWithSignatures:signatures]; if ([package booleanValueOfSignature:soft]) { // presumably you'd do something } if ([package firstObjectForSignature:inputFile]) { printf("dude, you gotta specify a file!\n"); return -1; } ``` -------------------------------- ### Multiple Values in a Group (Lazy Way) Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Demonstrates the 'lazy way' of assigning multiple values to flags within a group, where values are assigned based on their order. ```shell spiffy -io file1 file2 ``` -------------------------------- ### Multiple Values in a Group (Long Way) Source: https://github.com/mysteriouspants/argumentparser/blob/master/README.md Illustrates the 'long way' of assigning multiple values to flags within a group, explicitly specifying each flag and its value. ```shell spiffy -i file1 -o file2 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.