import chalk from "chalk" ; import { Runtime } from "./runtime" ; /**
 * Common arguments for all commands.
 */ export interface CommandArgs { /**
     * Location to run the command in.
     */ directory : string ; } /**
 * Args for a command that targets a single repository.
 */ export interface RepositoryCommandArgs extends CommandArgs { /**
     * Name of the repository.
     */ repository : string ; } template TArgs template TResults export type Command < TArgs extends CommandArgs = CommandArgs , TReturn = void > = ( runtime : Runtime , args : TArgs ) => Promise < TReturn > ; template TArgs param args param names export const ensureArgsExist = < TArgs extends { } > ( args , ... names ) : void => { const missing = names . filter ( ( name ) => ! ( name in args ) ) ; if ( ! missing . length ) { return ; } throw new Error ( chalk . red ( [ `Missing arg${ missing . length === 1 ? "" : "s" }:` , chalk . bold ( missing . join ( " " ) ) , ] . join ( " " ) ) ) ; } ; template TArgs param args param names export const defaultPathArgs = < TArgs extends CommandArgs > ( args , ... names ) : void => { for ( const name of names ) { if ( ! ( name in args ) ) { ( args as any ) [ name ] = "." ; } } } ;