Skip to content

Commit

Permalink
chore(cli): Provide clearer value names for language queries
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Aug 11, 2024
1 parent 2feeb25 commit 7aa8eb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ Language scopes:
interpolated)
- usings: `using` directives (including periods)

--csharp-query <CSHARP_QUERY>
--csharp-query <TREE-SITTER-QUERY>
Scope C# code using a custom tree-sitter query.
[env: CSHARP_QUERY=]
Expand All @@ -1380,7 +1380,7 @@ Language scopes:
- imports: Imports
- struct-tags: Struct tags

--go-query <GO_QUERY>
--go-query <TREE-SITTER-QUERY>
Scope Go code using a custom tree-sitter query.
[env: GO_QUERY=]
Expand All @@ -1407,7 +1407,7 @@ Language scopes:
- comments: Comments
- strings: Literal strings

--hcl-query <HCL_QUERY>
--hcl-query <TREE-SITTER-QUERY>
Scope HashiCorp Configuration Language code using a custom tree-sitter query.
[env: HCL_QUERY=]
Expand Down Expand Up @@ -1444,7 +1444,7 @@ Language scopes:
assignments)
- types: Types in type hints

--python-query <PYTHON_QUERY>
--python-query <TREE-SITTER-QUERY>
Scope Python code using a custom tree-sitter query.
[env: PYTHON_QUERY=]
Expand All @@ -1462,7 +1462,7 @@ Language scopes:
- strings: Strings (regular, raw, byte; includes interpolation parts in
format strings!)

--rust-query <RUST_QUERY>
--rust-query <TREE-SITTER-QUERY>
Scope Rust code using a custom tree-sitter query.
[env: RUST_QUERY=]
Expand All @@ -1477,7 +1477,7 @@ Language scopes:
- strings: Strings (literal, template)
- imports: Imports (module specifiers)

--typescript-query <TYPESCRIPT_QUERY>
--typescript-query <TREE-SITTER-QUERY>
Scope TypeScript code using a custom tree-sitter query.
[env: TYPESCRIPT_QUERY=]
Expand Down
15 changes: 9 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,9 @@ mod cli {
pub squeeze: bool,
}

/// For use as <https://docs.rs/clap/latest/clap/struct.Arg.html#method.value_name>
const TREE_SITTER_QUERY_VALUE_NAME: &str = "TREE-SITTER-QUERY";

#[derive(Parser, Debug)]
#[group(required = false, multiple = false)]
#[command(next_help_heading = "Language scopes")]
Expand All @@ -1189,7 +1192,7 @@ mod cli {
pub csharp: Option<PreparedCSharpQuery>,

/// Scope C# code using a custom tree-sitter query.
#[arg(long, env, verbatim_doc_comment)]
#[arg(long, env, verbatim_doc_comment, value_name = TREE_SITTER_QUERY_VALUE_NAME)]
pub csharp_query: Option<CustomCSharpQuery>,
}

Expand All @@ -1203,7 +1206,7 @@ mod cli {

#[allow(clippy::doc_markdown)] // CamelCase detected as 'needs backticks'
/// Scope HashiCorp Configuration Language code using a custom tree-sitter query.
#[arg(long, env, verbatim_doc_comment)]
#[arg(long, env, verbatim_doc_comment, value_name = TREE_SITTER_QUERY_VALUE_NAME)]
pub hcl_query: Option<CustomHclQuery>,
}

Expand All @@ -1215,7 +1218,7 @@ mod cli {
pub go: Option<PreparedGoQuery>,

/// Scope Go code using a custom tree-sitter query.
#[arg(long, env, verbatim_doc_comment)]
#[arg(long, env, verbatim_doc_comment, value_name = TREE_SITTER_QUERY_VALUE_NAME)]
pub go_query: Option<CustomGoQuery>,
}

Expand All @@ -1227,7 +1230,7 @@ mod cli {
pub python: Option<PreparedPythonQuery>,

/// Scope Python code using a custom tree-sitter query.
#[arg(long, env, verbatim_doc_comment)]
#[arg(long, env, verbatim_doc_comment, value_name = TREE_SITTER_QUERY_VALUE_NAME)]
pub python_query: Option<CustomPythonQuery>,
}

Expand All @@ -1239,7 +1242,7 @@ mod cli {
pub rust: Option<PreparedRustQuery>,

/// Scope Rust code using a custom tree-sitter query.
#[arg(long, env, verbatim_doc_comment)]
#[arg(long, env, verbatim_doc_comment, value_name = TREE_SITTER_QUERY_VALUE_NAME)]
pub rust_query: Option<CustomRustQuery>,
}

Expand All @@ -1251,7 +1254,7 @@ mod cli {
pub typescript: Option<PreparedTypeScriptQuery>,

/// Scope TypeScript code using a custom tree-sitter query.
#[arg(long, env, verbatim_doc_comment)]
#[arg(long, env, verbatim_doc_comment, value_name = TREE_SITTER_QUERY_VALUE_NAME)]
pub typescript_query: Option<CustomTypeScriptQuery>,
}

Expand Down

0 comments on commit 7aa8eb0

Please sign in to comment.