Skip to content

Conversation

@vikas-sharma24
Copy link
Contributor

@vikas-sharma24 vikas-sharma24 commented Dec 9, 2025

Add support to display mandatory and optional flags separately in CLI help

Sample CLI help command output:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli base64 --help
Usage:
  contract-cli base64 [flags]

Mandatory Flags:
  --in      Input data to encode (text or JSON)

Optional Flags:
  --format  Input data format (text or json)
  --help    help for base64
  --out     Path to save Base64 encoded output

Description

CLI currently does not differentiate between mandatory and optional flags in the help output. All flags are listed together, and users must rely on error messages to discover which flags are required. So enhancing the CLI to display required and optional flags separately.

Related Issue

Fixes #61

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Code refactor

Testing

Describe the tests you ran and how to reproduce them

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • I have updated the documentation
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass

@vikas-sharma24
Copy link
Contributor Author

vikas-sharma24 commented Dec 12, 2025

updated cli commands:
base64

vikassharma@vikass-mbp contract-cli % ./contract-cli base64 --help
Usage:
  contract-cli base64 [flags]

Mandatory Flags:
  --in      Input data to encode (text or JSON)

Optional Flags:
  --format  Input data format (text or json)
  --help    help for base64
  --out     Path to save Base64 encoded output

base64-tgz

vikassharma@vikass-mbp contract-cli % ./contract-cli base64-tgz --help
Usage:
  contract-cli base64-tgz [flags]

Mandatory Flags:
  --in      Path to folder containing docker-compose.yaml or pods.yaml

Optional Flags:
  --cert    Path to encryption certificate file
  --help    help for base64-tgz
  --os      Target Hyper Protect platform (hpvs, hpcr-rhvs, or hpcc-peerpod)
  --out     Path to save Base64 tar.gz output
  --output  Output format (plain or encrypted)

decrypt-attestation

vikassharma@vikass-mbp contract-cli % ./contract-cli decrypt-attestation --help
Usage:
  contract-cli decrypt-attestation [flags]

Mandatory Flags:
  --in    Path to encrypted attestation file (se-checksums.txt.enc)
  --priv  Path to private key file for signing

Optional Flags:
  --help  help for decrypt-attestation
  --out   Path to save decrypted attestation records

download-certificate

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli download-certificate --help
Usage:
  contract-cli download-certificate [flags]

Mandatory Flags:
  --version  Specific certificate versions to download (comma-separated, e.g., 1.0.21,1.0.22)

Optional Flags:
  --format   Output format for data (json, yaml, or text)
  --help     help for download-certificate
  --out      Path to save downloaded encryption certificates

encrypt

vikassharma@vikass-mbp contract-cli % ./contract-cli encrypt --help
Usage:
  contract-cli encrypt [flags]

Mandatory Flags:
  --in               Path to unencrypted contract YAML file

Optional Flags:
  --cacert           Path to CA certificate file (required with --contract-expiry)
  --cakey            Path to CA private key file (required with --contract-expiry)
  --cert             Path to encryption certificate file
  --contract-expiry  Enable contract expiry feature (requires CA cert and key)
  --csr              Path to Certificate Signing Request (CSR) file
  --csrParam         Path to CSR parameters JSON file
  --expiry           Contract validity period in days (required with --contract-expiry)
  --help             help for encrypt
  --os               Target Hyper Protect platform (hpvs, hpcr-rhvs, or hpcc-peerpod)
  --out              Path to save signed and encrypted contract
  --priv             Path to private key file for signing

encrypt-string

vikassharma@vikass-mbp contract-cli % ./contract-cli encrypt-string --help
Usage:
  contract-cli encrypt-string [flags]

Mandatory Flags:
  --in      String data to encrypt (text or JSON)

Optional Flags:
  --cert    Path to encryption certificate file
  --format  Input data format (text or json)
  --help    help for encrypt-string
  --os      Target Hyper Protect platform (hpvs, hpcr-rhvs, or hpcc-peerpod)
  --out     Path to save encrypted output

get-certificate

vikassharma@vikass-mbp contract-cli % ./contract-cli get-certificate --help
Usage:
  contract-cli get-certificate [flags]

Mandatory Flags:
  --in       Path to download-certificate JSON output
  --version  Certificate version to extract (e.g., 1.0.23)

Optional Flags:
  --help     help for get-certificate
  --out      Path to save extracted encryption certificate

image

vikassharma@vikass-mbp contract-cli % ./contract-cli image --help
Usage:
  contract-cli image [flags]

Mandatory Flags:
  --in       Path to IBM Cloud images JSON (from API, CLI, or Terraform)

Optional Flags:
  --format   Output format for data (json, yaml, or text)
  --help     help for image
  --out      Path to save HPCR image details
  --version  Specific HPCR version to retrieve (returns latest if not specified)

validate-contract

vikassharma@vikass-mbp contract-cli % ./contract-cli validate-contract --help
Usage:
  contract-cli validate-contract [flags]

Mandatory Flags:
  --in    Path to unencrypted Hyper Protect contract YAML file

Optional Flags:
  --help  help for validate-contract
  --os    Target Hyper Protect platform (hpvs, hpcr-rhvs, or hpcc-peerpod)

validate-encryption-certificate

vikassharma@vikass-mbp contract-cli % ./contract-cli validate-encryption-certificate --help
Usage:
  contract-cli validate-encryption-certificate [flags]

Mandatory Flags:
  --in    Versions of Encryption Certificates to validate, Seperated by coma(,)

Optional Flags:
  --help  help for validate-encryption-certificate

validate-network

vikassharma@vikass-mbp contract-cli % ./contract-cli validate-network --help
Usage:
  contract-cli validate-network [flags]

Mandatory Flags:
  --in    Path to network-config YAML file

Optional Flags:
  --help  help for validate-network

Copy link
Collaborator

@Sashwat-K Sashwat-K left a comment

Choose a reason for hiding this comment

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

Did you run make tidy ?

Copy link
Collaborator

@Sashwat-K Sashwat-K left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you @vikas-sharma24 for the continued contributions!

@Sashwat-K Sashwat-K merged commit 8d2adab into ibm-hyper-protect:main Dec 19, 2025
3 checks passed
@github-actions
Copy link

🎉 This PR is included in version 1.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

[Feature]: Add support to display mandatory and optional flags separately in CLI help

2 participants