mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Inline help
This commit is contained in:
parent
0353e1c6f4
commit
d5371b5dec
2 changed files with 96 additions and 82 deletions
|
@ -1,75 +0,0 @@
|
||||||
//! FIXME: write short doc here
|
|
||||||
|
|
||||||
pub const GLOBAL_HELP: &str = "ra-cli
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
ra_cli <SUBCOMMAND>
|
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-h, --help Prints help information
|
|
||||||
|
|
||||||
SUBCOMMANDS:
|
|
||||||
analysis-bench
|
|
||||||
analysis-stats
|
|
||||||
highlight
|
|
||||||
parse
|
|
||||||
symbols";
|
|
||||||
|
|
||||||
pub const ANALYSIS_BENCH_HELP: &str = "ra_cli-analysis-bench
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH]
|
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-h, --help Prints help information
|
|
||||||
-v, --verbose
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
--complete <PATH:LINE:COLUMN> Compute completions at this location
|
|
||||||
--highlight <PATH> Hightlight this file
|
|
||||||
|
|
||||||
ARGS:
|
|
||||||
<PATH> Project to analyse";
|
|
||||||
|
|
||||||
pub const ANALYSIS_STATS_HELP: &str = "ra-cli-analysis-stats
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH]
|
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-h, --help Prints help information
|
|
||||||
--memory-usage
|
|
||||||
-v, --verbose
|
|
||||||
-q, --quiet
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-o <ONLY>
|
|
||||||
|
|
||||||
ARGS:
|
|
||||||
<PATH>";
|
|
||||||
|
|
||||||
pub const HIGHLIGHT_HELP: &str = "ra-cli-highlight
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
ra_cli highlight [FLAGS]
|
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-h, --help Prints help information
|
|
||||||
-r, --rainbow";
|
|
||||||
|
|
||||||
pub const SYMBOLS_HELP: &str = "ra-cli-symbols
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
ra_cli highlight [FLAGS]
|
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-h, --help Prints help inforamtion";
|
|
||||||
|
|
||||||
pub const PARSE_HELP: &str = "ra-cli-parse
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
ra_cli parse [FLAGS]
|
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-h, --help Prints help inforamtion
|
|
||||||
--no-dump";
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
mod analysis_stats;
|
mod analysis_stats;
|
||||||
mod analysis_bench;
|
mod analysis_bench;
|
||||||
mod help;
|
|
||||||
mod progress_report;
|
mod progress_report;
|
||||||
|
|
||||||
use std::{error::Error, fmt::Write, io::Read};
|
use std::{error::Error, fmt::Write, io::Read};
|
||||||
|
@ -46,9 +45,20 @@ fn main() -> Result<()> {
|
||||||
match subcommand.as_str() {
|
match subcommand.as_str() {
|
||||||
"parse" => {
|
"parse" => {
|
||||||
if matches.contains(["-h", "--help"]) {
|
if matches.contains(["-h", "--help"]) {
|
||||||
eprintln!("{}", help::PARSE_HELP);
|
eprintln!(
|
||||||
|
"\
|
||||||
|
ra-cli-parse
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ra_cli parse [FLAGS]
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help inforamtion
|
||||||
|
--no-dump"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let no_dump = matches.contains("--no-dump");
|
let no_dump = matches.contains("--no-dump");
|
||||||
matches.finish().or_else(handle_extra_flags)?;
|
matches.finish().or_else(handle_extra_flags)?;
|
||||||
|
|
||||||
|
@ -61,10 +71,21 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
"symbols" => {
|
"symbols" => {
|
||||||
if matches.contains(["-h", "--help"]) {
|
if matches.contains(["-h", "--help"]) {
|
||||||
eprintln!("{}", help::SYMBOLS_HELP);
|
eprintln!(
|
||||||
|
"\
|
||||||
|
ra-cli-symbols
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ra_cli highlight [FLAGS]
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help inforamtion"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
matches.finish().or_else(handle_extra_flags)?;
|
matches.finish().or_else(handle_extra_flags)?;
|
||||||
|
|
||||||
let file = file()?;
|
let file = file()?;
|
||||||
for s in file_structure(&file) {
|
for s in file_structure(&file) {
|
||||||
println!("{:?}", s);
|
println!("{:?}", s);
|
||||||
|
@ -72,20 +93,51 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
"highlight" => {
|
"highlight" => {
|
||||||
if matches.contains(["-h", "--help"]) {
|
if matches.contains(["-h", "--help"]) {
|
||||||
eprintln!("{}", help::HIGHLIGHT_HELP);
|
eprintln!(
|
||||||
|
"\
|
||||||
|
ra-cli-highlight
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ra_cli highlight [FLAGS]
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help information
|
||||||
|
-r, --rainbow"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let rainbow_opt = matches.contains(["-r", "--rainbow"]);
|
let rainbow_opt = matches.contains(["-r", "--rainbow"]);
|
||||||
matches.finish().or_else(handle_extra_flags)?;
|
matches.finish().or_else(handle_extra_flags)?;
|
||||||
|
|
||||||
let (analysis, file_id) = Analysis::from_single_file(read_stdin()?);
|
let (analysis, file_id) = Analysis::from_single_file(read_stdin()?);
|
||||||
let html = analysis.highlight_as_html(file_id, rainbow_opt).unwrap();
|
let html = analysis.highlight_as_html(file_id, rainbow_opt).unwrap();
|
||||||
println!("{}", html);
|
println!("{}", html);
|
||||||
}
|
}
|
||||||
"analysis-stats" => {
|
"analysis-stats" => {
|
||||||
if matches.contains(["-h", "--help"]) {
|
if matches.contains(["-h", "--help"]) {
|
||||||
eprintln!("{}", help::ANALYSIS_STATS_HELP);
|
eprintln!(
|
||||||
|
"\
|
||||||
|
ra-cli-analysis-stats
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH]
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help information
|
||||||
|
--memory-usage
|
||||||
|
-v, --verbose
|
||||||
|
-q, --quiet
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
-o <ONLY>
|
||||||
|
|
||||||
|
ARGS:
|
||||||
|
<PATH>"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let verbosity = match (
|
let verbosity = match (
|
||||||
matches.contains(["-vv", "--spammy"]),
|
matches.contains(["-vv", "--spammy"]),
|
||||||
matches.contains(["-v", "--verbose"]),
|
matches.contains(["-v", "--verbose"]),
|
||||||
|
@ -110,6 +162,8 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
trailing.pop().unwrap()
|
trailing.pop().unwrap()
|
||||||
};
|
};
|
||||||
|
matches.finish().or_else(handle_extra_flags)?;
|
||||||
|
|
||||||
analysis_stats::run(
|
analysis_stats::run(
|
||||||
verbosity,
|
verbosity,
|
||||||
memory_usage,
|
memory_usage,
|
||||||
|
@ -121,9 +175,27 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
"analysis-bench" => {
|
"analysis-bench" => {
|
||||||
if matches.contains(["-h", "--help"]) {
|
if matches.contains(["-h", "--help"]) {
|
||||||
eprintln!("{}", help::ANALYSIS_BENCH_HELP);
|
eprintln!(
|
||||||
|
"\
|
||||||
|
ra_cli-analysis-bench
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH]
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help information
|
||||||
|
-v, --verbose
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
--complete <PATH:LINE:COLUMN> Compute completions at this location
|
||||||
|
--highlight <PATH> Hightlight this file
|
||||||
|
|
||||||
|
ARGS:
|
||||||
|
<PATH> Project to analyse"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let verbose = matches.contains(["-v", "--verbose"]);
|
let verbose = matches.contains(["-v", "--verbose"]);
|
||||||
let path: String = matches.opt_value_from_str("--path")?.unwrap_or_default();
|
let path: String = matches.opt_value_from_str("--path")?.unwrap_or_default();
|
||||||
let highlight_path: Option<String> = matches.opt_value_from_str("--highlight")?;
|
let highlight_path: Option<String> = matches.opt_value_from_str("--highlight")?;
|
||||||
|
@ -138,9 +210,26 @@ fn main() -> Result<()> {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
matches.finish().or_else(handle_extra_flags)?;
|
matches.finish().or_else(handle_extra_flags)?;
|
||||||
|
|
||||||
analysis_bench::run(verbose, path.as_ref(), op)?;
|
analysis_bench::run(verbose, path.as_ref(), op)?;
|
||||||
}
|
}
|
||||||
_ => eprintln!("{}", help::GLOBAL_HELP),
|
_ => eprintln!(
|
||||||
|
"\
|
||||||
|
ra-cli
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ra_cli <SUBCOMMAND>
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help information
|
||||||
|
|
||||||
|
SUBCOMMANDS:
|
||||||
|
analysis-bench
|
||||||
|
analysis-stats
|
||||||
|
highlight
|
||||||
|
parse
|
||||||
|
symbols"
|
||||||
|
),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue