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

Access flags from command #144

Open
timvol opened this issue Mar 9, 2020 · 0 comments
Open

Access flags from command #144

timvol opened this issue Mar 9, 2020 · 0 comments

Comments

@timvol
Copy link

timvol commented Mar 9, 2020

I've a main.js and a main-serve.js file. The main.js contains the following:

const args = require('args')

args
  .option('port', 'The port on which the app will be running', 3000)
  .command('serve', 'Serves API', ['s'])

args.parse(process.argv)

When I start my application let's say "node main.js serve -p 5000", how can I access the flags parsed in main.js inside main-serve.js? I already tried "console.log(process.env)" in main-serve to check if the flags are passed using environment variables but that's not the case. So, how can I access the flags from main-serve.js?

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

No branches or pull requests

1 participant