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

Drop cobra dependency #42

Merged
merged 6 commits into from
Aug 26, 2024
Merged

Drop cobra dependency #42

merged 6 commits into from
Aug 26, 2024

Conversation

End-rey
Copy link
Contributor

@End-rey End-rey commented Aug 21, 2024

Close #34.

Use default flag package instead of cobra and use go run instead of build binary in Makefile.

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 53 lines in your changes missing coverage. Please review.

Project coverage is 28.75%. Comparing base (81106c9) to head (66eb971).
Report is 17 commits behind head on master.

Files Patch % Lines
internal/generate/main.go 0.00% 53 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
+ Coverage   25.94%   28.75%   +2.80%     
==========================================
  Files          23       21       -2     
  Lines         767      793      +26     
==========================================
+ Hits          199      228      +29     
- Misses        533      540       +7     
+ Partials       35       25      -10     

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

Use default flag package instead of cobra.

Closes #34.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Now the binary code is not created, but just runs through go run. Also removed
unnecessary things and improved the code style.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@End-rey End-rey force-pushed the 34-drop-cobra-dependency branch from 6f6a9bf to 61a066c Compare August 21, 2024 16:18
roman-khimov
roman-khimov previously approved these changes Aug 21, 2024
flag.StringVar(&locodeGenerateOutPath, locodeGenerateOutputFlag, "", "Target path for generated database (directory))")
}

func Execute() {
Copy link
Contributor

Choose a reason for hiding this comment

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

it can be main now

Copy link
Contributor

Choose a reason for hiding this comment

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

@End-rey now it's a main pkg in internal/ containing executable program which is usually placed in cmd/, may be move it there in concert?

Copy link
Member

Choose a reason for hiding this comment

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

may be move it there in concert?

but why? i think it is internaled intentionally. no one is expected to use it, it is for our generations only

Copy link
Contributor

Choose a reason for hiding this comment

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

cuz its a common approach across various Go projects. I can use it from intenal as well, and placing program into cmd does not force usage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cthulhu-rider Do you propose to make such structure?

.
├── cmd
│    └── generate
│            └── main.go
├── internal
└── pkg

I agree that then the structure will be better and the command code will be separated from the library code.
But why haven't we used such a structure before? Were there any significant reasons for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

such structure?

exactly

But why haven't we used such a structure before?

idk, this isnt a big problem so no one cared i guess

Copy link
Member

Choose a reason for hiding this comment

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

That's mostly because this command is completely internal, it's supposed to be used only by package developers. And the only thing properly exposed to the outside world is pkg/locodedb.

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 mostly because this command is completely internal, it's supposed to be used only by package developers. And the only thing properly exposed to the outside world is pkg/locodedb.

That is, to leave the structure as it is now? main.go in internal?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's weird to have main package in internal, at least it should be internal/generate. With this, it's easy to make it cmd/generate and not to go against the generally accepted approach

Move all from generate.go to main.go and make Execute main function.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Use flag.Func to obtain string slice instead of flag.Var.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Resolve problem with specific os PATH.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@roman-khimov roman-khimov merged commit 90c03dd into master Aug 26, 2024
9 of 10 checks passed
@roman-khimov roman-khimov deleted the 34-drop-cobra-dependency branch August 26, 2024 07:26
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.

Drop cobra dependency
4 participants