()
| 26 | |
| 27 | export class Program extends BaseProgram { |
| 28 | async register() { |
| 29 | program |
| 30 | .option("--pretty", "Format output. JSON is tabbed with two spaces.") |
| 31 | .option("--raw", "Return raw output instead of a descriptive message.") |
| 32 | .option("--response", "Return a JSON formatted version of response output.") |
| 33 | .option("--cleanexit", "Exit with a success exit code (0) unless an error is thrown.") |
| 34 | .option("--quiet", "Don't return anything to stdout.") |
| 35 | .option("--nointeraction", "Do not prompt for interactive user input.") |
| 36 | .option("--session <session>", "Pass session key instead of reading from env.") |
| 37 | .version( |
| 38 | await this.serviceContainer.platformUtilsService.getApplicationVersion(), |
| 39 | "-v, --version", |
| 40 | ); |
| 41 | |
| 42 | program.on("option:pretty", () => { |
| 43 | process.env.BW_PRETTY = "true"; |
| 44 | }); |
| 45 | |
| 46 | program.on("option:raw", () => { |
| 47 | process.env.BW_RAW = "true"; |
| 48 | }); |
| 49 | |
| 50 | program.on("option:quiet", () => { |
| 51 | process.env.BW_QUIET = "true"; |
| 52 | }); |
| 53 | |
| 54 | program.on("option:response", () => { |
| 55 | process.env.BW_RESPONSE = "true"; |
| 56 | }); |
| 57 | |
| 58 | program.on("option:cleanexit", () => { |
| 59 | process.env.BW_CLEANEXIT = "true"; |
| 60 | }); |
| 61 | |
| 62 | program.on("option:nointeraction", () => { |
| 63 | process.env.BW_NOINTERACTION = "true"; |
| 64 | }); |
| 65 | |
| 66 | program.on("option:session", (key) => { |
| 67 | process.env.BW_SESSION = key; |
| 68 | }); |
| 69 | |
| 70 | program.on("command:*", () => { |
| 71 | writeLn(chalk.redBright("Invalid command: " + program.args.join(" ")), false, true); |
| 72 | writeLn("See --help for a list of available commands.", true, true); |
| 73 | process.exitCode = 1; |
| 74 | }); |
| 75 | |
| 76 | program.on("--help", () => { |
| 77 | writeLn( |
| 78 | chalk.yellowBright( |
| 79 | "\n Tip: Managing and retrieving secrets for dev environments is easier with Bitwarden Secrets Manager. Learn more under https://bitwarden.com/products/secrets-manager/", |
| 80 | ), |
| 81 | ); |
| 82 | writeLn("\n Examples:"); |
| 83 | writeLn(""); |
| 84 | writeLn(" bw login"); |
| 85 | writeLn(" bw lock"); |
no test coverage detected