{"name":"@percy/cli-command","version":"1.0.0-beta.59","license":"MIT","_id":"@percy/cli-command@1.0.0-beta.59","dist":{"shasum":"b66c206120ddcd5e291f78072c21d9057971ad8a","tarball":"http://registry-npm.ywwl.com/@percy/cli-command/download/@percy/cli-command-1.0.0-beta.59.tgz","fileCount":7,"integrity":"sha512-iY5oYL9pYVuuvwEXMXjAXEeQ37sBO2HEvUmQyedtWPhEqwhps3hbKOzk6jKVWF8PJMBAy8ZASNg5kb7ggj7l2A==","signatures":[{"sig":"MEYCIQCon7mJb0enwlq9W9p4V+fKmQXvPIo6UUdDuq8Gz52zWAIhAJaqXxncsqf5Ams4BRCC3LtCMV3rqnOWFWLbrz02NYfj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10121,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9apbCRA9TVsSAnZWagAAhIIP+gJGfL+R00T5FFriaTxg\nFedEBraxVrLbJBYM2VJTM6e48+vgvCNTtwRN82f2GsxCSSGsRvxOqIc+S3RT\nmARB8P8eynlrY9xtp4jAsOF9gQcLb5k8kir/8GVCxfFjLK0AjfFWEvKsNawE\nwJyM0BCXhcQb/jOnupNFQgbxDJDhi1CpYs+lPRpiK3Kzp8sECB1J61jznvrt\nKPpRUGLtEcGxdXVJt7sc+CtuvYdrhxQnHbhumvQcqbCnoKiqCI4/k3U+Eq2q\nriWO7FLBt/ODpuMTlZtZrfopezj4bLxAjx2oJMT8enZsNnS2R71NysFMs3iB\nTOI9WfuEY5vHYhH5xxn1Vmo1lEeIjK+KHiIXbfk1PseQrmtAZcu3J1NW6z9H\n/fYDc86Ggs7pqBcY7y7eYEFagv5tJGUfbrR8v5xQ5ucSVy5zgxexnP+QVvUn\ncc80k956A5j0cu1UcM8w4Nyjlaqz6ejsSojiSkGR59fusBQYMoPwU47sLKhx\nSKizFxSDHRW1pCKsT4FnpCLTsqYXF7bQKG1+HaO+Nd39yilCcBer5JGzuakx\n0D4NkGtW3lo/7m1YzajdDKFJPXo7LUHU968hoFHx+5D98a/C42msYAwU3jyP\ngJ1t4VCySziFPuUmMhJQXjBFMw8NglVzy1QGBtOHMZnSW2jeX60cV/i1Ed/d\nYnml\r\n=RA/p\r\n-----END PGP SIGNATURE-----\r\n","size":3988,"noattachment":false,"key":"/@percy/cli-command/-/@percy/cli-command-1.0.0-beta.59.tgz"},"main":"dist/index.js","types":"types/index.d.ts","engines":{"node":">=12"},"gitHead":"bcc5b6da44aef8927cc3acb9406f5ee54ba4dde0","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"},"_npmVersion":"lerna/4.0.0/node@v14.17.3+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.3","dependencies":{"@oclif/config":"^1.17.0","@percy/config":"^1.0.0-beta.59","@percy/logger":"^1.0.0-beta.59","@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.59_1626712667457_0.9146577962191313","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":1626712667575,"maintainers":[{"name":"percy-admin","email":"apps+npm@percy.io"}],"_cnpm_publish_time":1626712667575,"dist-tags":{"alpha":"1.31.15-alpha.0","beta":"1.33.0-beta.0","latest":"1.33.1"}}