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

Convert Golang compliant flags to POSIX compliant #2030

Merged
merged 3 commits into from
Jun 18, 2024
Merged

Conversation

kislaykishore
Copy link
Collaborator

Golang flags don't distinguish between single-hyphen and double-hyphen flags. POSIX compliant flags that are supported by pflag and Cobra however require flags to be prefixed with double hyphens. So, augment the flags in os.Args by converting the single-hyphen flags to double-hyphen ones so that they can be consumed by Cobra and Viper.

Description

Link to the issue in case of a bug fix.

NA

Testing details

  1. Manual - NA
  2. Unit tests - NA
  3. Integration tests - NA

Golang flags don't distinguish between single-hyphen and double-hyphen
flags. POSIX compliant flags that are supported by pflag and Cobra
however require flags to be prefixed with double hyphens. So, augment
the flags in os.Args by converting the single-hyphen flags to double-hyphen ones.
@kislaykishore kislaykishore requested a review from a team as a code owner June 18, 2024 05:58
-v has special meaning for Cobra which it uses to print version. Don't
convert it to --v
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.78%. Comparing base (b6eca68) to head (640881b).
Report is 3 commits behind head on master.

Files Patch % Lines
main.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2030      +/-   ##
==========================================
+ Coverage   71.40%   71.78%   +0.37%     
==========================================
  Files          97       98       +1     
  Lines       10708    10851     +143     
==========================================
+ Hits         7646     7789     +143     
+ Misses       2719     2718       -1     
- Partials      343      344       +1     
Flag Coverage Δ
unittests 71.78% <88.88%> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kislaykishore kislaykishore merged commit 27eda37 into master Jun 18, 2024
13 checks passed
@kislaykishore kislaykishore deleted the args-compat branch June 18, 2024 08:59
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