Skip to content

Conversation

@fmuyassarov
Copy link
Member

Improve user experience.

  • add usage examples to export and compat commands
  • add -p short flag for --path option
  • silence usage output on runtime errors for cleaner error messages

Examples

  1. Usage silencing (before)

    $ ./bin/nfd export features --pathd
    Error: unknown flag: --pathd
    Usage:
      nfd export features [flags]
    
    Flags:
      -h, --help          help for features
          --path string   export to this JSON path
    
    unknown flag: --pathd
    

    after

    $ ./bin/nfd export features --pathd
    Error: unknown flag: --pathd
    unknown flag: --pathd
    

    before

    $  ./bin/nfd  compat validate-node --output-jsond true
    Error: unknown flag: --output-jsond
    Usage:
      nfd compat validate-node [flags]
    
    Flags:
      -h, --help                       help for validate-node
          --image string               the URL of the image containing compatibility metadata
          --output-json                print a JSON object
          --plain-http                 use of HTTP protocol for all registry communications
          --platform string            the artifact platform in the format os[/arch][/variant][:os_version]
          --registry-password-stdin    read registry password from stdin
          --registry-token-stdin       read registry access token from stdin
          --registry-username string   registry username
          --tags strings               a list of tags that must match the tags set on the compatibility objects
    
    unknown flag: --output-jsond
    

    after

    $ ./bin/nfd  compat validate-node --output-jsond true
    Error: unknown flag: --output-jsond
    unknown flag: --output-jsond
    
  2. Helper examples:

    $ ./bin/nfd export features -h
    Export features for given node
    
    Usage:
      nfd export features [flags]
    
    Examples:
    
    # Export node features to stdout (prints to terminal)
    nfd export features
    
    # Export node features to a file instead
    nfd export features --path /tmp/features.json
    
    Flags:
      -h, --help          help for features
      -p, --path string   export to this JSON path
    

- Add usage examples to export and compat commands
- Add `-p` short flag for `--path` option
- Silence usage output on runtime errors for cleaner error messages

Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@est.tech>
@netlify
Copy link

netlify bot commented Oct 29, 2025

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit f06db58
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-nfd/deploys/69021471c6ad6c00088b4441
😎 Deploy Preview https://deploy-preview-2349--kubernetes-sigs-nfd.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 29, 2025
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 29, 2025
Copy link
Contributor

@marquiz marquiz left a comment

Choose a reason for hiding this comment

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

Thanks @fmuyassarov for the enhancement, looks good to me

@mfranczy @ChaoyiHuang @vsoch

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2025
@fmuyassarov
Copy link
Member Author

/cc @ArangoGutierrez

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances CLI usability by adding usage examples to subcommands and improving error handling. The changes include setting SilenceUsage = true on the root command to prevent double output on errors, adding example sections to three commands (features, labels, and validate-node), and adding shorthand -p flags to the --path options for better ergonomics.

  • Suppresses usage output on command errors via RootCmd.SilenceUsage = true
  • Adds example documentation to export and validation commands
  • Adds shorthand -p flag for --path option in export commands

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cmd/nfd/subcmd/root.go Sets SilenceUsage to prevent usage output on errors
cmd/nfd/subcmd/export/labels.go Adds example documentation and shorthand flag for path option
cmd/nfd/subcmd/export/features.go Adds example documentation and shorthand flag for path option
cmd/nfd/subcmd/compat/validate-node.go Adds example documentation for validation command

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to +40
nfd export features
# Export node labels to a file instead
nfd export features --path /tmp/labels.json`
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The example text shows 'nfd export features' but this is the 'labels' command. The examples should use 'nfd export labels' instead to match the command being documented.

Suggested change
nfd export features
# Export node labels to a file instead
nfd export features --path /tmp/labels.json`
nfd export labels
# Export node labels to a file instead
nfd export labels --path /tmp/labels.json`

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@ArangoGutierrez ArangoGutierrez left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 10, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 46937a65abc1648f390ea038cd9cea4b355967f3

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ArangoGutierrez, fmuyassarov, marquiz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [ArangoGutierrez,marquiz]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit eef4278 into kubernetes-sigs:master Nov 10, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants