You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.1 KiB

4 years ago
  1. /// <reference types="q"/>
  2. export const Arg: undefined;
  3. export const Opt: undefined;
  4. export function Cmd(cmd?: classes.Cmd): classes.Cmd;
  5. export namespace classes {
  6. class Arg {
  7. constructor(cmd: Cmd);
  8. name(name: string): Arg;
  9. title(title: string): Arg;
  10. arr(): Arg;
  11. req(): Arg;
  12. val(validation: (this: Arg, value: any) => boolean): Arg;
  13. def(def: any): Arg;
  14. output(): Arg;
  15. comp(fn: (opts: any) => any): Arg;
  16. end(): Cmd;
  17. apply(...args: any[]): Arg;
  18. input(): Arg;
  19. reject(...args: any[]): Arg;
  20. }
  21. class Cmd {
  22. constructor(cmd?: Cmd);
  23. static create(cmd?: Cmd): Cmd;
  24. api(): any;
  25. name(name: string): Cmd;
  26. title(title: string): Cmd;
  27. cmd(cmd?: Cmd): Cmd;
  28. opt(): Opt;
  29. arg(): Arg;
  30. act(act: (opts: any, args: any[], res: any) => any, force?: boolean): Cmd;
  31. apply(fn: Function, args?: any[]): Cmd;
  32. comp(fs: (opts: any) => any): Cmd;
  33. helpful(): Cmd;
  34. completable(): Cmd;
  35. usage(): string;
  36. run(argv: string[]): Cmd;
  37. invoke(cmds?: string|string[], opts?: any, args?: any): Q.Promise<any>;
  38. reject(reason: any): Q.Promise<any>;
  39. end(): Cmd;
  40. do(argv: string[]): any;
  41. extendable(pattern?: string): Cmd;
  42. }
  43. class Opt {
  44. constructor(cmd?: Cmd);
  45. name(name: string): Opt;
  46. title(title: string): Opt;
  47. short(short: string): Opt;
  48. long(long: string): Opt;
  49. flag(): Opt;
  50. arr(): Opt;
  51. req(): Opt;
  52. only(): Opt;
  53. val(validation: (this: Opt, value: any) => boolean): Opt;
  54. def(def: any): Opt;
  55. input(): Opt;
  56. output(): Opt;
  57. act(act: (opts: any, args: any[], res: any) => any): Opt;
  58. comp(fn: (opts: any) => any): Opt;
  59. end(): Cmd;
  60. apply(...args: any[]): void;
  61. reject(...args: any[]): void;
  62. }
  63. }
  64. export namespace shell {
  65. function escape(w: string): string;
  66. function unescape(w: string): string;
  67. }