UI for Zipcoin Blue

options.d.ts 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import * as minimist from 'minimist';
  2. import { CommandLineOptions, CommandMetadata, CommandMetadataInput, CommandMetadataOption, HydratedCommandOption, HydratedParseArgsOptions, MetadataGroup, ParsedArg } from '../definitions';
  3. export declare const parseArgs: typeof minimist;
  4. export { ParsedArgs } from 'minimist';
  5. /**
  6. * Remove options, which are any arguments that starts with a hyphen (-), from
  7. * a list of process args and return the result.
  8. *
  9. * If a double-hyphen separator (--) is encountered, it and the remaining
  10. * arguments are included in the result, as they are not interpreted. This
  11. * behavior can be disabled by setting the `includeSeparated` option to
  12. * `false`.
  13. */
  14. export declare function stripOptions(pargv: string[], {includeSeparated}: {
  15. includeSeparated?: boolean;
  16. }): string[];
  17. /**
  18. * Split a list of process args into own-arguments and other-arguments, which
  19. * are separated by the double-hyphen (--) separator.
  20. *
  21. * For example, `['cmd', 'arg1', '--', 'arg2']` will be split into
  22. * `['cmd', 'arg1']` and `['arg2']`.
  23. */
  24. export declare function separateArgv(pargv: string[]): [string[], string[]];
  25. /**
  26. * Takes a Minimist command option and normalizes its values.
  27. */
  28. export declare function hydrateCommandMetadataOption<O extends CommandMetadataOption>(option: O): O & HydratedCommandOption;
  29. export declare function metadataToParseArgsOptions(metadata: CommandMetadata): HydratedParseArgsOptions;
  30. export declare type OptionPredicate<O extends CommandMetadataOption> = (option: O, value?: ParsedArg) => boolean;
  31. export declare namespace OptionFilters {
  32. function includesGroups<O extends CommandMetadataOption>(groups: MetadataGroup | MetadataGroup[]): OptionPredicate<O>;
  33. function excludesGroups<O extends CommandMetadataOption>(groups: MetadataGroup | MetadataGroup[]): OptionPredicate<O>;
  34. }
  35. /**
  36. * Given a command metadata object and an object of parsed options, match each
  37. * supplied option with its command metadata option definition and pass it,
  38. * along with its value, to a predicate function, which is used to return a
  39. * subset of the parsed options.
  40. *
  41. * Options which are unknown to the command metadata are always excluded.
  42. *
  43. * @param predicate If excluded, `() => true` is used.
  44. */
  45. export declare function filterCommandLineOptions<M extends CommandMetadata<I, O>, I extends CommandMetadataInput, O extends CommandMetadataOption>(metadata: M, parsedArgs: CommandLineOptions, predicate?: OptionPredicate<O>): CommandLineOptions;
  46. /**
  47. * Given a command metadata object and an object of parsed options, return a
  48. * subset of the parsed options whose command metadata option definition
  49. * contains the supplied group(s).
  50. *
  51. * Options which are unknown to the command metadata are always excluded.
  52. *
  53. * @param groups One or more option groups.
  54. */
  55. export declare function filterCommandLineOptionsByGroup<M extends CommandMetadata<I, O>, I extends CommandMetadataInput, O extends CommandMetadataOption>(metadata: M, parsedArgs: CommandLineOptions, groups: MetadataGroup | MetadataGroup[]): CommandLineOptions;
  56. export interface UnparseArgsOptions {
  57. useDoubleQuotes?: boolean;
  58. useEquals?: boolean;
  59. ignoreFalse?: boolean;
  60. allowCamelCase?: boolean;
  61. }
  62. /**
  63. * The opposite of `parseArgs()`. This function takes parsed args and converts
  64. * them back into an argv array of arguments and options.
  65. */
  66. export declare function unparseArgs(parsedArgs: minimist.ParsedArgs, {useDoubleQuotes, useEquals, ignoreFalse, allowCamelCase}: UnparseArgsOptions): string[];