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

fix: support CLIs with single top level command #426

Merged
merged 2 commits into from Jun 14, 2022

Conversation

mdonnalley
Copy link
Contributor

@mdonnalley mdonnalley commented Jun 13, 2022

Support CLIs with a single top level command (i.e. the executable is the only command).

With this fix, users will need to do two things:

  1. Place their command at the top level of the commands dir, e.g. src/commands/index.ts
  2. Supply the default in their oclif config, for example
oclif: {
  default: ".",
  commands: "./dist/commands"
}

Fixes #425

@felipecrs
Copy link
Contributor

Please let me know if the below migration would be correct then:

  1. Add to package.json:
{
  "oclif": {
    "default": ".",
    "commands": "./lib" // as my "index.ts" is at "src/index.ts" and my tsc builds to "lib"
  }
}

@mdonnalley
Copy link
Contributor Author

Please let me know if the below migration would be correct then:

  1. Add to package.json:
{
  "oclif": {
    "default": ".",
    "commands": "./lib" // as my "index.ts" is at "src/index.ts" and my tsc builds to "lib"
  }
}

That should also work

@felipecrs
Copy link
Contributor

It works, but the --help now displays two sections (while it should only display the first):

bin/dev --help
Downloads and extracts binaries from compressed packages using a config file

USAGE
  $ bindl . [--version] [--help] [-c <value>]

FLAGS
  -c, --config=<value>  Path to the config file
  --help                Show CLI help.
  --version             Show CLI version.

DESCRIPTION
  Downloads and extracts binaries from compressed packages using a config file

  The config will be read from any valid config file in the current directory. The configuration file can be defined
  using all the extensions and names accepted by cosmiconfig, such as bindl.config.js



Downloads and extracts binaries from compressed packages using a config file

VERSION
  bindl/2.0.0 wsl-x64 node-v16.15.1

USAGE
  $ bindl [COMMAND]

COMMANDS
  .  Downloads and extracts binaries from compressed packages using a config file

@felipecrs
Copy link
Contributor

felipecrs commented Jun 13, 2022

Another issue:

  • bindl . triggers the main command (while it should actually pass . as argument to the main command).

@mdonnalley
Copy link
Contributor Author

mdonnalley commented Jun 14, 2022

@felipecrs I pushed a commit last night that should resolve the issues you're seeing - let me know if that works better for you

@RodEsp RodEsp merged commit 44adb4d into main Jun 14, 2022
@RodEsp RodEsp deleted the mdonnalley/support-single-clis branch June 14, 2022 15:12
@felipecrs
Copy link
Contributor

@mdonnalley thank you! I will test and let you know.

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.

Migrate single command cli to @oclif/core
3 participants