cli.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { Options } from './options';
  2. import { Program, Programs } from './programs';
  3. /**
  4. * The Cli contains the usage and the collection of programs.
  5. *
  6. * Printing help for all the programs in the following order:
  7. * usage, commands, and options. If the options are used in multiple programs,
  8. * it will list it once.
  9. */
  10. export declare class Cli {
  11. programs: Programs;
  12. usageText: string;
  13. version: string;
  14. /**
  15. * Register a program to the command line interface.
  16. * @returns The cli for method chaining.
  17. */
  18. program(prog: Program): Cli;
  19. /**
  20. * Add a usage for the command line interface.
  21. * @returns The cli for method chaining.
  22. */
  23. usage(usageText: string): Cli;
  24. /**
  25. * Prints help for the programs registered to the cli.
  26. */
  27. printHelp(): void;
  28. /**
  29. * For commands, gets the position where the description should start so they
  30. * are aligned.
  31. * @returns The position where the command description should start.
  32. */
  33. posCmdDescription(): number;
  34. /**
  35. * For options, gets the position where the description should start so they
  36. * are aligned.
  37. * @returns The position where the option description should start.
  38. */
  39. posDescription(): number;
  40. /**
  41. * For options, get the position where the default values should start so they
  42. * are aligned.
  43. * @returns The position where the option default values should start.
  44. */
  45. posDefault(): number;
  46. /**
  47. * Go through all programs and add options to the collection.
  48. * @returns The options used in the programs.
  49. */
  50. getOptions(): Options;
  51. /**
  52. * Get the options used by the programs and create the minimist options
  53. * to ensure that minimist parses the values properly.
  54. * @returns The options for minimist.
  55. */
  56. getMinimistOptions(): Object;
  57. }