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

Fix ordering of options, flags and subcommands #227

Merged
merged 5 commits into from
Dec 4, 2022

Conversation

VPetukhov
Copy link
Contributor

This PR fixes #226 . It additionally sorts all subcommands alphabetically. Tests for ordering are also there.

Code to test by hands:

module M1
using Comonicon

"""
Run cell segmentation

# Options

- `-x`: Name of x column. Overrides the config value.
- `-y`: Name of y column. Overrides the config value.
- `-z`: Name of z column. Overrides the config value.
- `-g`: Name of gene column. Overrides the config value.
"""
@cast function main(;x::String, y::String, z::String, g::String)
    print("Hello, world")
end

@cast function test(;x::String, y::String, z::String, g::String)
    print("Hello, world")
end

@cast function run(;x::String, y::String, z::String, g::String)
    print("Hello, world")
end

@main
end

M1.command_main()
M1.command_main(["main"])

@codecov
Copy link

codecov bot commented Dec 2, 2022

Codecov Report

Base: 83.71% // Head: 82.89% // Decreases project coverage by -0.82% ⚠️

Coverage data is based on head (2936333) compared to base (67c7e60).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 2936333 differs from pull request most recent head d61e572. Consider uploading reports for the commit d61e572 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #227      +/-   ##
==========================================
- Coverage   83.71%   82.89%   -0.83%     
==========================================
  Files          21       21              
  Lines        1584     1584              
==========================================
- Hits         1326     1313      -13     
- Misses        258      271      +13     
Impacted Files Coverage Δ
src/ast/types.jl 100.00% <ø> (ø)
src/frontend/types.jl 100.00% <ø> (ø)
src/ast/printing.jl 87.77% <100.00%> (ø)
src/codegen/julia.jl 89.13% <100.00%> (ø)
src/frontend/cast.jl 81.62% <100.00%> (ø)
src/frontend/markdown.jl 94.48% <100.00%> (ø)
src/builder/install.jl 75.67% <0.00%> (-17.57%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Roger-luo
Copy link
Collaborator

I think the main concern of having an extra dependency on OrderedCollections initially was the loading time impact which can be critical for use cases like CLI tools. But this PR seems OK on 1.8 (maybe due to compiler improvements)

julia> @time using Comonicon #master
  0.085131 seconds (278.01 k allocations: 20.346 MiB)
julia> @time using Comonicon # this PR
  0.084021 seconds (278.05 k allocations: 20.348 MiB)

@@ -9,6 +9,7 @@ ExproniconLite = "55351af7-c7e9-48d6-89ff-24e801d99491"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Copy link
Collaborator

Choose a reason for hiding this comment

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

need to add a compat field for OrderedCollections in this file too

src/Comonicon.jl Outdated Show resolved Hide resolved
src/ast/ast.jl Outdated Show resolved Hide resolved
src/ast/printing.jl Outdated Show resolved Hide resolved
@VPetukhov
Copy link
Contributor Author

@Roger-luo , thanks for the comments! I made the changes, and they're ready for a review :)

@Roger-luo
Copy link
Collaborator

Roger-luo commented Dec 4, 2022

Anyway, I think I can change the CASTED_COMMANDS part directly, thanks for the PR! see comment above, we will keep CASTED_COMMANDS as is, thanks!

@Roger-luo Roger-luo merged commit 29a975d into comonicon:master Dec 4, 2022
@VPetukhov
Copy link
Contributor Author

Yeah, my bad, that's what I meant. Instead of saying that CASTED_COMMANDS are passed from the package scope, but not the Comonicon scope, I said it was passed from the runtime. Thanks!

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.

[BUG] Option ordering is messed up because of converting Docstring to a Dictionary
2 participants