command.d.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { analytics, logging } from '@angular-devkit/core';
  9. import { Arguments, CommandContext, CommandDescription, CommandDescriptionMap, CommandScope, CommandWorkspace, Option, SubCommandDescription } from './interface';
  10. export interface BaseCommandOptions {
  11. help?: boolean | string;
  12. }
  13. export declare abstract class Command<T extends BaseCommandOptions = BaseCommandOptions> {
  14. readonly description: CommandDescription;
  15. protected readonly logger: logging.Logger;
  16. allowMissingWorkspace: boolean;
  17. workspace: CommandWorkspace;
  18. analytics: analytics.Analytics;
  19. protected static commandMap: () => Promise<CommandDescriptionMap>;
  20. static setCommandMap(map: () => Promise<CommandDescriptionMap>): void;
  21. constructor(context: CommandContext, description: CommandDescription, logger: logging.Logger);
  22. initialize(options: T & Arguments): Promise<void>;
  23. printHelp(options: T & Arguments): Promise<number>;
  24. printJsonHelp(_options: T & Arguments): Promise<number>;
  25. protected printHelpUsage(): Promise<void>;
  26. protected printHelpSubcommand(subcommand: SubCommandDescription): Promise<void>;
  27. protected printHelpOptions(options?: Option[]): Promise<void>;
  28. validateScope(scope?: CommandScope): Promise<void>;
  29. reportAnalytics(paths: string[], options: T & Arguments, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
  30. abstract run(options: T & Arguments): Promise<number | void>;
  31. validateAndRun(options: T & Arguments): Promise<number | void>;
  32. }