GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(spec): expose package metadata by jdx · Pull Request #1116 · jdx/usage

feat(spec): expose package metadata #1116

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.

Sign up for GitHub

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

Merged
jdx merged 4 commits into agent/refresh-fleet-fixtures from agent/root-package-metadata
Aug 20, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(spec): expose package metadata #1116

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
59f352a
feat(spec): expose package metadata
jdx Aug 20, 2026
e9724ff
fix(spec): update conformance metadata tables
jdx Aug 20, 2026
3b8e1b5
fix(spec): accept package metadata expressions
jdx Aug 20, 2026
49e751e
fix(derive): reject nested package metadata
jdx Aug 20, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
fix(spec): accept package metadata expressions
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@jdx
jdx committed Aug 20, 2026
commit 3b8e1b570fd81327a3772a90de6e3e4f88e30f77

There are no files selected for viewing

2 changes: 2 additions & 0 deletions 2 cli/assets/usage.1
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,5 @@ Arguments to pass to script

Anything `usage` does not recognise is a value rather than a mistake, which is what
lets a shebang script take flags of its own.
.SH SOURCE
https://github.com/jdx/usage
6 changes: 3 additions & 3 deletions 6 derive/src/codegen.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ pub fn emit(cli: &Cli) -> TokenStream {
Some(tokens) => quote!(::core::option::Option::Some(#tokens)),
None => quote!(::core::option::Option::None),
};
let author = option_str(cli.author.as_deref());
let license = option_str(cli.license.as_deref());
let repository = option_str(cli.repository.as_deref());
let author = option_expr(cli.author.as_ref());
let license = option_expr(cli.license.as_ref());
let repository = option_expr(cli.repository.as_ref());
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

let about = cli
.about_attr
.as_ref()
Expand Down
16 changes: 10 additions & 6 deletions 16 derive/src/model.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ pub struct Cli {
/// From the struct's doc comment: first paragraph, and the whole thing.
pub about: Option<String>,
pub long_about: Option<String>,
pub author: Option<String>,
pub license: Option<String>,
pub repository: Option<String>,
/// Package metadata expressions whose results must be usable as `&'static str`.
///
/// Keeping their tokens lets the Cargo-provided `env!("CARGO_PKG_…")` values remain the
/// source of truth instead of making adopters repeat those strings in the derive attribute.
pub author: Option<proc_macro2::TokenStream>,
pub license: Option<proc_macro2::TokenStream>,
pub repository: Option<proc_macro2::TokenStream>,
/// Whether a flag-like token that names no flag is a value or an error. Unset
/// means the spec's default, which is `value`.
pub unknown_flags: Option<String>,
Expand Down Expand Up @@ -693,9 +697,9 @@ impl Cli {
// declared.
"about" => cli.about_attr = Some(metadata_expr(&meta)?),
"long_about" => cli.long_about_attr = Some(metadata_expr(&meta)?),
"author" => cli.author = Some(string_value(&meta)?),
"license" => cli.license = Some(string_value(&meta)?),
"repository" => cli.repository = Some(string_value(&meta)?),
"author" => cli.author = Some(metadata_expr(&meta)?),
"license" => cli.license = Some(metadata_expr(&meta)?),
"repository" => cli.repository = Some(metadata_expr(&meta)?),
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

"before_help" => cli.before_help = Some(metadata_expr(&meta)?),
"next_help_heading" => cli.next_help_heading = Some(string_value(&meta)?),
"before_long_help" => cli.before_long_help = Some(metadata_expr(&meta)?),
Expand Down
2 changes: 2 additions & 0 deletions 2 docs/cli/reference/index.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

**Version**: 5.1.0

**Repository**: https://github.com/jdx/usage

Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

- **Usage**: `usage [--completions <COMPLETIONS>] [--usage-spec] <SUBCOMMAND>`

## Flags
Expand Down
21 changes: 12 additions & 9 deletions 21 usage-rs/tests/facade.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,29 @@ enum Command {
#[derive(Cli)]
#[usage(
bin = "metadata",
author = "Example Maintainers",
license = "MIT OR Apache-2.0",
repository = "https://example.com/tool"
author = env!("CARGO_PKG_AUTHORS"),
license = env!("CARGO_PKG_LICENSE"),
repository = env!("CARGO_PKG_REPOSITORY")
)]
struct PackageMetadata;

#[test]
fn package_metadata_survives_spec_emission() {
let kdl = PackageMetadata::to_kdl();
assert!(kdl.contains("author \"Example Maintainers\""), "{kdl}");
assert!(kdl.contains("license \"MIT OR Apache-2.0\""), "{kdl}");
assert!(kdl.contains("author \"Jeff Dickey @jdx\""), "{kdl}");
assert!(kdl.contains("license MIT"), "{kdl}");
assert!(
kdl.contains("repository \"https://example.com/tool\""),
kdl.contains("repository \"https://github.com/jdx/usage\""),
"{kdl}"
);

let spec: usage_parser::Spec = kdl.parse().expect("usage-lib should read derive output");
assert_eq!(spec.author.as_deref(), Some("Example Maintainers"));
assert_eq!(spec.license.as_deref(), Some("MIT OR Apache-2.0"));
assert_eq!(spec.repository.as_deref(), Some("https://example.com/tool"));
assert_eq!(spec.author.as_deref(), Some("Jeff Dickey @jdx"));
assert_eq!(spec.license.as_deref(), Some("MIT"));
assert_eq!(
spec.repository.as_deref(),
Some("https://github.com/jdx/usage")
);
}

#[test]
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402860 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.