Skip to content

Conversation

@vikas-sharma24
Copy link
Contributor

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

Description

Added support to give error flag name in error if required flag is missing

Related Issue

Fixes #69

Type of Change

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

Testing

Added all test result here: #68 (comment)

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

Updated command response if required flag is missing

base64:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli base64
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
2025/12/24 12:41:57 Error: required flag '--in' is missing.

base64-tgz:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli base64-tgz 
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)
2025/12/24 12:42:11 Error: required flag '--in' is missing.

decrypt-attestation:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli decrypt-attestation 
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
2025/12/24 12:42:36 Error: required flag --in, --priv are missing.

download-certificate:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli download-certificate 
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
2025/12/24 12:42:57 required flag --version is missing

encrypt:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli encrypt
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
2025/12/24 12:43:15 Error: required flag '--in' is missing.

encrypt-string:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli encrypt-string
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
2025/12/24 12:43:34 Error: required flag '--in' is missing.

get-certificate:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli get-certificate
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
2025/12/24 12:43:50 Error: required flag --in, --version are missing.

image:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli image
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)
2025/12/24 12:44:07 Error: required flag '--in' is missing.

validate-contract:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli validate-contract
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)
2025/12/24 12:44:25 Error: required flag '--in' is missing.

validate-encryption-certificate:

vikassharma@Vikass-MacBook-Pro contract-cli % ./contract-cli validate-encryption-certificate
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
2025/12/24 12:44:43 Error: required flag '--in' is missing.

validate-network:

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

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

Optional Flags:
  --help  help for validate-network
2025/12/24 12:45:01 Error: required flag '--in' is missing.

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.

Lets make the error come first and then the help after few lines.

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 give error flag name if required flag is missing

2 participants