You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Couple of possible issues (or unlisted expectations) with the Usage of the README:
Appears to require a package.json set with type: 'module'?
Error returned when running: Cannot use import statement outside a module
--help doesn't seem to work after patching to use require()
TypeError: cmd._help is not a function - had this elsewhere when migrating, couldn't find where _help was supposed to be set to try and debug it
Possibly to be raised elsewhere? Advice on how to refer to this usage scenario when raising that bug would be appreciated.
To Reproduce
Steps to reproduce the behavior:
Init a new npm package (npm init)
Add oclif (npm install -S oclif)
Create myscript with contents matching Usage
Make executable (chmod +x myscript)
Run it (./myscript)
Expected behavior
Command output roughly matches the README
Environment (please complete the following information):
Win11 w/ PowerShell
or Debian buster + bash-5.0
Additional context
As mentioned above - had issues with the --help flag when migrating (from 1.x) using the same sort of file structure as the one used in this repo's Usage section, so figured I'd start again from scratch at that point. Not sure if the help not working is a bug with the help code or an issue with how it's used in the example?
Patched source below, updated to use require() and formatted to pass our eslint checks so my editor doesn't complain:
#!/usr/bin/env ts-node
constfs=require('fs');const{Command, Flags}=require('@oclif/core');classLSextendsCommand{staticflags={version: Flags.version(),help: Flags.help(),// run with --dir= or -d=dir: Flags.string({char: 'd',default: process.cwd(),}),};asyncrun(){const{flags}=awaitthis.parse(LS);letfiles=fs.readdirSync(flags.dir);for(letfoffiles){this.log(f);}}}LS.run().catch(require('@oclif/core/handle'));
The text was updated successfully, but these errors were encountered:
@tr00st Thanks for filing the issue. I just created #532 to update the example and to fix the broken --help flag.
As a side note, I'd encourage you to use a generated cli (npx oclif generate my-cli) instead of trying to use oclif/core in a script. While it should work for you, it's not a use case we can put a lot of support towards right now
Describe the bug
Couple of possible issues (or unlisted expectations) with the Usage of the README:
type: 'module'
?Cannot use import statement outside a module
require()
TypeError: cmd._help is not a function
- had this elsewhere when migrating, couldn't find where_help
was supposed to be set to try and debug itTo Reproduce
Steps to reproduce the behavior:
npm init
)npm install -S oclif
)myscript
with contents matching Usagechmod +x myscript
)./myscript
)Expected behavior
Command output roughly matches the README
Environment (please complete the following information):
Additional context
As mentioned above - had issues with the
--help
flag when migrating (from 1.x) using the same sort of file structure as the one used in this repo's Usage section, so figured I'd start again from scratch at that point. Not sure if the help not working is a bug with the help code or an issue with how it's used in the example?Patched source below, updated to use
require()
and formatted to pass our eslint checks so my editor doesn't complain:The text was updated successfully, but these errors were encountered: