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

chore: Get executable name from the command #326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dwertent
Copy link
Contributor

This PR enhances the FireFly CLI by making the executable name dynamic in the help messages. Instead of hardcoding the executable name, it is now loaded from the command-line arguments, allowing for dynamic help messages that reflect the actual executable name being used.

Before:

% firefly

To get started run: ff init
Optional: Set FIREFLY_HOME env variable for FireFly stack configuration path.

Usage:
  ff [command]

After:

% firefly

To get started run: firefly init
Optional: Set FIREFLY_HOME env variable for FireFly stack configuration path.

Usage:
  firefly [command]

Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are missing a few such as ff start message after an ff init

cmd/root.go Outdated Show resolved Hide resolved
cmd/root.go Outdated Show resolved Hide resolved
Signed-off-by: dwertent <david.wertenteil@kaleido.io>
@@ -53,7 +56,7 @@ func GetFireflyASCIIArt() string {

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "ff",
Use: ExecutableName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to make this usage message better

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not part of this PR

@EnriqueL8
Copy link
Contributor

You are getting a build error because of
image

@@ -39,6 +39,9 @@ var logger log.Logger = &log.StdoutLogger{
LogLevel: log.Debug,
}

// name of the executable, this is for the help messages
var ExecutableName string = os.Args[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if this arg has paths it will show up...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, but it's intentional based on how it's being used. For example:

% ./path/to/exec/ff

To get started, run: ./path/to/exec/ff init
Optional: Set the FIREFLY_HOME environment variable for FireFly stack configuration path.

Usage:
  ./path/to/exec/ff [command]

Available Commands:
  accounts    Work with accounts in a FireFly stack
  completion  Generate the autocompletion script for the specified shell
  deploy      Deploy a compiled smart contract
  docs        Generate markdown documentation for all commands
  help        Help about any command
  info        Get info about a stack
  init        Create a new FireFly local dev stack
  list        List stacks
  logs        View log output from a stack
  ps          Returns information on running stacks
  pull        Pull a stack
  remove      Completely remove a stack
  reset       Clear all data in a stack
  start       Start a stack
  stop        Stop a stack
  upgrade     Upgrade a stack to a different version
  version     Prints the version info

Flags:
      --ansi string   Control when to print ANSI control characters ("never"|"always"|"auto") (default "auto")
  -h, --help          Help for ./ff/ff
  -v, --verbose       Verbose log output

Use "./path/to/exec/ff [command] --help" for more information about a command.

As you can see, the executable was built locally in a subpath, so it makes sense for the help messages to reflect the subpath. This way, users can simply copy and paste the command from the help message without needing to adjust the path manually.

@dwertent
Copy link
Contributor Author

I think the build failed due to a failure in the coverage report generation, maybe we should re-run the build job (it passed last time and the only change I made was the var name)

@EnriqueL8
Copy link
Contributor

I reran it and it's still failing

@EnriqueL8
Copy link
Contributor

I'm quite puzzled about why we are getting a broken pipe, might some related to etcd-io/etcd#17560 or the permission in the workflow

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