{"name":"@percy/cli-command","version":"1.0.0-beta.66","license":"MIT","_id":"@percy/cli-command@1.0.0-beta.66","homepage":"https://github.com/percy/cli#readme","bugs":{"url":"https://github.com/percy/cli/issues"},"dist":{"shasum":"a0abe083968e06a28406e9c93c7f87c02cdbaf48","tarball":"http://registry-npm.ywwl.com/@percy/cli-command/download/@percy/cli-command-1.0.0-beta.66.tgz","fileCount":7,"integrity":"sha512-pvqK+KH7KW/ArcrYb/GkmcUNBN0gHFEY/PiEmOp7qcOwOM8fAIID87WD5BL/OeZGut78n4zzs5+xOYbpzpEjVg==","signatures":[{"sig":"MEQCICh7jTu4p7K3q3fOLsrH2zXWPZuT1X5keUFs/77kChSJAiAh3QI8HujtEgm4H2PxecJsXd7x7MqCSQmMIBn8T6kKsA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10522,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhJT0ACRA9TVsSAnZWagAARmQP/0QvsNIRPAIbfDgBDUGA\n6tKQjiIGtVWMF0HzTQvCtfwxLmbQxziiL+LykuqFN188eN4/ho0A/iG0uzYD\nQp4W+/Ac3imWy5DdAqwD8os/NnPyoIKVPGg2OBYfvVmoa3AjQvzyFpxN5ZLG\n9bINN6UlOjcBozeOF00L+tJbXxvdEVH4SVclWJPyrOa20LAZpzY6LoHSS3+r\n6S6IJh9vzJMc8VAtCVLOUq3l5Y5D9M/YA6USMvoJII5rOMIw33vE1i4TzxS6\n4+HG8LDuzwz/Fl46eaS1n3Q480znK3xt8u/8d1axbpTHaM9nYh05NlbRWP1Z\n/l+HfaIPioT1OOTdkZNbs/2BmJ1QE5TTbWrRMfI0lP8Fjgs68SBhQ6UUgz/h\ngu04Cgn/83CNTgW57HL92U6IclKQgGoAvsz/oT/3VV3kGnoftrNU6dFN6BxE\n9QeonOccl6dtUDCIWACmCnv+07x8MvMbm4zhCPp57xNq+nvIC0LKlUKS1kCA\nW7ExTZADO78xVoYMo1lEgFr1IpBo+Yfmp6U0eE8iLb0BREybPz8ZJ8Qal8P0\nXWb/ZPiZ3lHrw7h9kheMTvTjvyABC62RyEcbrDcStGMc5qDCFcavO/RNr+GH\nWadX/Xz0ViOT+cCywbFj+B8R0tnADvCj6PVqTvkroPfMvmWOlHzBvpRbX4t0\ne8LF\r\n=YKy1\r\n-----END PGP SIGNATURE-----\r\n","size":4166,"noattachment":false,"key":"/@percy/cli-command/-/@percy/cli-command-1.0.0-beta.66.tgz"},"main":"dist/index.js","types":"types/index.d.ts","engines":{"node":">=12"},"gitHead":"740a335bab4966f7dda4e4693505e17a5fdcfd4c","scripts":{"lint":"eslint --ignore-path ../../.gitignore .","test":"node ../../scripts/test","build":"node ../../scripts/build","test:types":"tsd","test:coverage":"yarn test --coverage"},"_npmUser":{"name":"percy-admin","email":"apps+npm@percy.io"},"repository":{"url":"git+https://github.com/percy/cli.git","type":"git","directory":"packages/cli-command"},"_npmVersion":"lerna/4.0.0/node@v14.17.5+x64 (linux)","description":"The base command class that Percy CLI commands should extend from. Adds commonly used configuration options to Percy config files, a `#percyrc()` method for parsing config files, and other shared methods. Also provides common CLI flags along with oclif fl","directories":{},"_nodeVersion":"14.17.5","dependencies":{"@oclif/config":"^1.17.0","@percy/config":"1.0.0-beta.66","@percy/logger":"1.0.0-beta.66","@oclif/command":"^1.8.0","@oclif/plugin-help":"^3.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cli-command_1.0.0-beta.66_1629830400240_0.5490062364477735","host":"s3://npm-registry-packages"},"readme":"# @percy/cli-command\n\nPercy CLI command parser and runner.\n\n- [Usage](#usage)\n- [Options](#options)\n  - [Args](#args)\n  - [Flags](#flags)\n  - [Percy](#percy)\n\n## Usage\n\nThe `command` function accepts a name, definition, and callback and returns a runner function that\naccepts an array of command-line arguments.\n\n``` js\nimport command from '@percy/cli-command';\n\n// example command runner\nconst example = command('example', {\n  description: 'Example command description',\n  // positional arguments\n  args: [\n    { name: 'one' }\n  ],\n  // flags and options\n  flags: [\n    { name: 'foo' }, // boolean by default\n    { name: 'bar', type: 'string' }\n  ],\n  // shows in help output\n  examples: [\n    // $0 will be replaced by the command name\n    '$0 --foo --bar baz qux'\n  ]\n}, ({ flags, args }) => {\n  // see below for other available properties\n  console.log({ flags, args });\n});\n\n// remove the script name from argv\nexample(process.argv.slice(2));\n```\n\n``` shell\n$ node ./example --foo --bar baz qux\n{ flags: { foo: true, bar: 'baz' }, args: { one: 'qux' } }\n```\n\n## Options\n\nOnly a command `name` is required. However, without any other options, a command will only show the\ndefault help output with global flags. A command's `callback` will be called when the resulting\ncommand runner is invoked with an array of command-line arguments. How those arguments are\ninterpreted and parsed is defined by the command's `definition`.\n\n- `name` — The command name shown in help output, also used to match nested commands.\n- `definition` — A command definition object defines various options to control help output, the\n  arguments parser, and other percy options.\n  - `description` — The command description shown in help output.\n  - `usage` — Custom command usage shown in help output.\n  - `examples` — An array of example strings to show in help output.\n  - `version` — A version string to display via a `-V, --version` flag.\n  - `commands` — An array or function returning an array of nested subcommands.\n  - `flags` — Optional flag arguments accepted by the command ([see below](#flags)).\n  - `args` — Positional arguments accepted by the command ([see below](#args)).\n  - `percy` — Enable creation of a core percy instance ([see below](#percy)).\n  - `config` — Automatic percy config registration ([see below](#percy)).\n  - `loose` — Push unknown arguments to `argv`. A string value will log as a warning when unknown\n    arguments are first encountered by the parser.\n  - `exitOnError` — Call `process.exit()` if the command encounters an error while running.\n- `callback` — The command callback invoked after the runner is called with command-line arguments\n  and after those arguments are interpreted by the internal parser.\n\nThe `callback` argument can be a function, an async function, or an async generator function. Given\nan async generator function, the command becomes cancelable via process interruption and is able to\nclean up after itself using traditional try-catch error handling.\n\nThe `callback` function is invoked with a single argument containing various contextual properties\naccording to the command definition:\n\n- `flags` — An object containing key-value pairs of flag arguments interpreted by the parser as\n  determined by the flag's respective definition ([see below](#flags)).\n- `args` — An object containing key-value pairs of positional arguments interpreted by the parser as\n  determined by the arg's respective definition ([see below](#args)).\n- `argv` — An array of unknown arguments that were not parsed due to either the `loose` option or\n  the presence of an end-of-arguments delimiter (`--`).\n- `percy` — An instance of `@percy/core` only present when a corresponding `percy` definition option\n  is provided ([see below](#percy)).\n- `log` — A `@percy/logger` group namespaced under the command's `name`. The initial loglevel is\n  optionally determined by various global logging flags (`--verbose`, `--silent`, `--quiet`).\n- `exit` — Utility function to stop the execution of a command from within the runner. Accepts\n  an exit code (default `1`) and an exit reason (default `'EEXIT: ${exitCode}'`). The function will\n  throw an error which can be handled, or let bubble where the presence of `exitOnError` will cause\n  the process to exit with the provided exit code.\n\n### Flags\n\nEach flag definition must contain either a `name` or a `short` option. By default, all flags will be\ninterpreted as boolean flags and will produce an error if a value is provided. Setting the `type`\noption to anything other than `'boolean'` will allow providing command-line values and error if one\n_is not_ provided.\n\n- `name` — The flag name (i.e. `--flag-name`).\n- `short` — The flag short character (i.e. `-s`).\n- `type` — The flag type as displayed in help output.\n- `default` — The flag's default value when not provided.\n- `parse` — A function used to parse any provided flag value.\n- `validate` — A function that should throw an error when the provided flag value is invalid.\n- `attribute` — A string or function returning a string to set the value at on the `callback`\n  argument's `flags` property. Defaults to the camelcase `name` or `short` character.\n- `percyrc` — A string to map this flag to percy config options ([see below](#percy)).\n- `deprecated` — A boolean, string, or tuple used to warn about a deprecated flag and optionally map\n  it to an alternate flag ([see below](#deprecations)).\n\n### Args\n\nPositional args correspond to their definition index, so the arg definition at index `0` will match\nthe first provided command-line argument that is not a flag or subcommand. By default, positional\nargs are optional, but can be configured to be required or have default values.\n\n- `name` — The arg name shown in help output.\n- `required` — Indicate that this flag is required, which causes an error when not provided.\n- `default` — The arg's default value when not provided.\n- `parse` — A function used to parse the provided argument.\n- `validate` — A function that should throw an error when the provided argument is invalid.\n- `attribute` — A string or function returning a string to set the value at on the `callback`\n  argument's `args` property. Defaults to camelcase `name`.\n- `percyrc` — A string to map this arg to percy config options ([see below](#percy)).\n- `deprecated` — A boolean, string, or tuple used to warn about a deprecated arg and optionally map\n  it to a flag ([see below](#deprecations)).\n\n#### Deprecations\n\nWhen the `deprecated` option is `true` and the flag or positional arg has been provided by\ncommand-line arguments, a deprecation warning will be logged. A string value indicates the version\nin which this argument will be removed and is reflected in the deprecation message.\n\n<details>\n  <summary>Remapping deprecated arguments</summary><br>\n\nWhen providing a tuple, the version is the first option of the tuple, while the second option can be\nan alternate flag to use, or a recommendation message to display when the deprecation warning is\nlogged. Given an alternate flag, the value will be automatically mapped to the corresponding flag's\nattribute name on the `callback` argument's `flags` property.\n\n``` js\n{ name: 'foo', deprecated: true }\n// [percy] Warning: The '--foo' option will be removed in a future release.\n\n{ name: 'foo', deprecated: 'v2.0.0' }\n// [percy] Warning: The '--foo' option will be removed in v2.0.0.\n\n{ name: 'foo', deprecated: ['v2.0.0', '--bar'] }\n// [percy] Warning: The '--foo' option will be removed in v2.0.0. Use '--bar' instead.\n\n{ name: 'foo', deprecated: ['v2.0.0', 'Use the config file option instead.'] }\n// [percy] Warning: The '--foo' option will be removed in v2.0.0. Use the config file option instead.\n```\n</details>\n\n### Percy\n\nThe `percy` definition option accepts an object consisting of `@percy/core` options. The presence of\nthis option will add shared percy flags to accepted command-line arguments and provide the command\ncallback with a percy instance initialized with the provided options.\n\nWhen the `percy` definition option is `true`, shared percy flags will not be accepted, but a default\npercy instance will still be provided to the command callback when run. Regardless of the `percy`\noption, if the environment variable `PERCY_ENABLE` is `0`, the callback _will not_ receive a percy\ninstance (and can act accordingly).\n\n- `percy` — Enables creation of a `@percy/core` instance initialized with provided options.\n\n#### Config\n\nAcceptable percy config file options can be extended before the file is loaded via\n`PercyConfig.addSchema()` and `PercyConfig.addMigration()`. These functions can be called before the\ncommand is run to achieve the same effect as including them in the command definition. However, the\npresence of a `percy` definition option will also signal `@percy/core` config schemas and migrations\nto be automatically registered before the following options are registered.\n\n- `config` — Percy config schemas and migrations to register while creating the command runner.\n  - `schemas` — An array of percy config schemas to automatically register.\n  - `migrations` — An array of percy config migrations to automatically register.\n\nAdditionally, flags and positional arguments that define a `percyrc` option will have their\nassociated values mapped to a corresponding `percy` property that is used when initializing a\n`@percy/core` instance. Provided options are validated against config schemas and are made available\non the command callback argument's `percy.config` property.\n","publish_time":1629830400370,"maintainers":[{"name":"percy-admin","email":"apps+npm@percy.io"}],"_cnpm_publish_time":1629830400370,"dist-tags":{"alpha":"1.31.15-alpha.0","beta":"1.33.0-beta.0","latest":"1.33.1"}}