Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parsing of CLI arguments and forwarding to Providers #2

Merged
merged 2 commits into from
Sep 15, 2014
Merged

Conversation

fabdrol
Copy link
Member

@fabdrol fabdrol commented Sep 14, 2014

In this branch I've added the parsing of CLI arguments (using minimalist) and forwarding these to all Providers. Providers now receive the server (app) instance as the first argument to the init method, through which they can access the parsed arguments.

  • Launch the server with the --execute argument: node ./index --execute=echo\ '{ "some": [ "stringified", "signal", "k" ] }'
  • execute.js runs with the command specified after --execute=. execute.js should give a good idea of how this is achieved and provide a starting point for Provider development.

Access to the CLI arguments in a Provider can be achieved by:

  • Accessing the parsed arguments at app.argv (returns a plain object with the arguments and their names)
  • Accessing the raw arguments array at app.__argv

Since the server instance is provided to the init() method by default, Providers could also add route endpoints to the web server (app is a Express instance wrapped with some extra information).

Other changes:

  • I've updated my editor settings, should be 2 spaces soft-tabs (=indents) now. If a file is still 4-space hard-tabs, that is because I haven't touched it. If your editor updates it to 2 spaces indents, it should remain like that from now on.
  • Updated package.json to the right name and the right repo URL, also added a "contributors" list
  • Removed bonjour.js

fabdrol pushed a commit that referenced this pull request Sep 15, 2014
Added parsing of CLI arguments and forwarding to Providers
@fabdrol fabdrol merged commit dd5d392 into master Sep 15, 2014
@fabdrol fabdrol deleted the config branch September 15, 2014 07:39
@fabdrol fabdrol restored the config branch September 15, 2014 07:39
@fabdrol fabdrol deleted the config branch September 15, 2014 07:40
@fabdrol
Copy link
Member Author

fabdrol commented Sep 15, 2014

@tkurki you mean the global settings file?

Any Provider-specific settings can be done using cli args for now.. Re setting CLI options: atm that isn't necessary, as the server basically accepts all arguments. That isn't the best way to go about it (it isn't very user friendly, for one - the user needs to look up what args to use in the providers documentation) but I'd say it's a good start. Maybe we should move to getopts as soon as the functionality to set options is in. I'll keep you posted!

@fabdrol fabdrol restored the config branch September 24, 2014 09:20
@fabdrol fabdrol deleted the config branch November 23, 2014 12:59
tkurki pushed a commit that referenced this pull request Oct 15, 2017
tkurki added a commit that referenced this pull request Mar 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants