Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

New dredd init & config & CLI #1101

Open
7 of 11 tasks
honzajavorek opened this issue Aug 6, 2018 · 3 comments
Open
7 of 11 tasks

New dredd init & config & CLI #1101

honzajavorek opened this issue Aug 6, 2018 · 3 comments
Labels
Epic: configuration Command line options, dredd init, dredd.yml

Comments

@honzajavorek
Copy link
Contributor

honzajavorek commented Aug 6, 2018

This is a proposal on how to tackle the dredd init + dredd.yml epic.

Parts of Dredd affected

  • dredd init wizard
  • configuration
  • dredd.yml

Requirements

Solutions

New CLI

Clearly distinguish commands, arguments, and options. Notes:

  • dredd init, --config indicates where to save the file, --init doesn't exist, remove -i
  • dredd names <api description filename - or - url> <api description filename - or - url> ... (formerly --names)
  • dredd <api description filename - or - url> <server url>
  • (dredd.yml exists) dredd <api description filename - or - url - or apiary subdomain/url> <server url> overrides the dredd.yml values
  • (dredd.yml exists) dredd --api-description=... overrides the dredd.yml value
  • --api-description=... is instead of --path
  • (dredd.yml exists) dredd --server-url=... overrides the dredd.yml value
  • dredd --version = dredd version (alias)
  • dredd --help is command-specific, e.g. dredd names --help
  • dredd --hookfiles= changes to dredd --hooks=
  • --language is not required if it can be detected from --hooks= files extensions, otherwise there should be aliases (python = python-dredd-hooks binary etc.) or it is treated as a custom hooks handler (works now, but not documented)
  • Sandbox is only allowed when --language is resolved as nodejs or javascript or js, otherwise it should fail
  • The CLI arguments should fail in general in case they don't make sense together (e.g. --server-wait without --server
  • I'm not even sure what --details, -d does and whether anyone uses it
  • Clearly distinguish all default values and whether particular option is boolean or not

Downloading API description from Apiary

  • Currently there's -j/--custom with custom configuration and apiaryApiName with apiaryApiKey properties, where apiaryApiName is a unique identifier of the API project in Apiary
  • We could leave --custom completely to user-specific stuff and pass it on to hooks (see 7bffde7#r29826481) - Access Custom options in Hooks #215
  • Dredd could accept the identifier instead of the API description file name or URL: dredd myapi http://localhost:4000 this is dangerous and non-deterministic and we would hate ourselves for such design decision
  • Dredd could accept --apiary-api-name
  • Call the thing consistently as API NAME, api-name, or apiName, to be consistent with the Apiary CLI
  • Dredd could have --apiary-api-key option instead of apiaryApiKey and accept APIARY_API_KEY= env var as well (to work together with the Apiary CLI)
  • When testing happens with correct Apiary configuration and there is no local file given, Dredd downloads the API description document as if it was given URL, and tests against it
  • When there is both api name and local file, dredd makes a request to Apiary API, checks the checksum and identifies whether the local document is up-to-date. It warns if it's not up-to-date.
  • The Tutorial in Apiary turns to $ dredd init --apiary-api-name=myapi --apiary-api-key=9a5.... --reporter=apiary
@honzajavorek honzajavorek added the Epic: configuration Command line options, dredd init, dredd.yml label Aug 6, 2018
@honzajavorek
Copy link
Contributor Author

honzajavorek commented Aug 6, 2018

@honzajavorek honzajavorek mentioned this issue Aug 10, 2018
3 tasks
@honzajavorek
Copy link
Contributor Author

  • --hooks=... (files)
  • --hooks-handler=... (binary path or keyword like python, js, js-sandbox)
  • remove --sandbox in favor of the -sandbox suffix (see above)
  • js, nodejs, and javascript are aliases
  • the --hooks-handler value default is detected from the --hooks value (extensions) or set to JavaScript, so most of the time the option isn't needed at all
  • special value custom allows for Allow bypassing handler spawning logic #755, doesn't spawn anything, but sends the data to given hook handler host and port (prints out where it's sending the data... could do this always anyway)
  • rename --hooks-worker-* to --hooks-handler-*
  • --server=... (binary path)

@honzajavorek honzajavorek changed the title New dredd init & config New dredd init & config & CLI Jan 10, 2019
@artem-zakharchenko
Copy link
Contributor

  • Separate validation/normalization/coercing logic during Dredd config application
  • Provide proper override priority between CLI args, dredd.yml and default config
  • Make config options deprecation more maintainable
  • Prevent propagation of aliases into CLI args config (i.e. l, q, etc.), use full option names instead (may require migration to another CLI commands handler than optimist)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Epic: configuration Command line options, dredd init, dredd.yml
Projects
None yet
Development

No branches or pull requests

2 participants