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

Update help message comments. Closes #517 #527

Merged
merged 12 commits into from
Apr 24, 2023
28 changes: 15 additions & 13 deletions src/command_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,42 @@ use serde::Serialize;
#[derive(Debug, Default, Parser)]
#[command(rename_all = "kebab-case")]
pub struct SliceOptions {
/// List of slice files to compile.
/// List of Slice files to compile.
#[arg(required = true)]
pub sources: Vec<String>,

/// Files that are needed for referencing, but that no code should be generated for.
#[arg(short = 'R', long, num_args = 1, action = Append)]
/// Reference Slice file or directory containing Slice files. Reference files are used to resolve definitions in
/// the Slice sources being compiled. Directories are searched recursively. This option can be repeated.
externl marked this conversation as resolved.
Show resolved Hide resolved
#[arg(short = 'R', long = "reference", num_args = 1, action = Append)]
pub references: Vec<String>,

/// Preprocessor Symbols defined on the command line.
#[arg(short = 'D', long, num_args = 1, action = Append)]
/// Define a preprocessor definition. Preprocessor definitions do not have an associated value.
externl marked this conversation as resolved.
Show resolved Hide resolved
/// This option can be repeated.
Copy link
Member

Choose a reason for hiding this comment

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

What about: "Comma separated list of preprocessor symbols that will be defined for the compilation"

Choose a reason for hiding this comment

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

We don't support comma separated lists, if you want to define multiple symbols, each one needs a -D in front of it:
okay: slicec-cs.exe test.slice -D foo -DBar
bad: slicec-cs.exe test.slice -D foo,bar

Copy link
Member

Choose a reason for hiding this comment

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

mm ok, the --help output posted earlier mentioned the comma thing

          Define a preprocessor definition. Preprocessor definitions do not have an associated value. Multiple values can be specified by using multiple `-D|--definition` options or by using a comma

#[arg(short = 'D', long = "define", num_args = 1, action = Append)]
pub definitions: Vec<String>,

/// Instructs the compiler to treat warnings as errors.
/// Instruct the compiler to treat warnings as errors.
#[arg(short, long)]
pub warn_as_error: bool,

/// Instructs the compiler to allow warnings. Specify a list of warnings to allow, or leave empty to allow all
/// warnings.
#[arg(long)]
pub allow_warnings: Option<Vec<String>>,
/// Instruct the compiler to allow the specified warning. An allowed warning will not be emitted as a
/// diagnostic. This option can be repeated.
externl marked this conversation as resolved.
Show resolved Hide resolved
#[arg(short = 'A', long = "allow")]
pub allowed_warnings: Option<Vec<String>>,

/// Validates input files without generating code for them.
/// Validate input files without generating code for them.
#[arg(long)]
pub dry_run: bool,

/// Output directory for generated code, defaults to the current working directory.
/// Set the output directory for the generated code, defaults to the current working directory.
externl marked this conversation as resolved.
Show resolved Hide resolved
#[arg(long)]
pub output_dir: Option<String>,

/// Output format for emitted errors.
externl marked this conversation as resolved.
Show resolved Hide resolved
#[arg(value_enum, default_value_t = DiagnosticFormat::Human, long, ignore_case = true)]
pub diagnostic_format: DiagnosticFormat,

/// Disables ANSI escape code for diagnostic output.
/// Disable ANSI escape code for diagnostic output.
externl marked this conversation as resolved.
Show resolved Hide resolved
#[arg(long)]
pub disable_color: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion src/diagnostics/diagnostic_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl DiagnosticReporter {
treat_warnings_as_errors: slice_options.warn_as_error,
diagnostic_format: slice_options.diagnostic_format,
disable_color: slice_options.disable_color,
allowed_warnings: slice_options.allow_warnings.clone(),
allowed_warnings: slice_options.allowed_warnings.clone(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/diagnostic_output_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ error [E010]: invalid enum 'E': enums must contain at least one enumerator
// Set the output format to JSON.
let options = SliceOptions {
diagnostic_format: DiagnosticFormat::Json,
allow_warnings: Some(vec![]),
allowed_warnings: Some(vec![]),
..Default::default()
};

Expand Down Expand Up @@ -151,7 +151,7 @@ error [E010]: invalid enum 'E': enums must contain at least one enumerator
// Set the output format to JSON.
let options = SliceOptions {
diagnostic_format: DiagnosticFormat::Json,
allow_warnings: Some(vec!["W004".to_string()]),
allowed_warnings: Some(vec!["W004".to_string()]),
..Default::default()
};

Expand Down