compiler/stage2_l0/src/cli_args.l0
Module cli_args
Overview Symbols grouped by source file: compiler/stage2_l0/src/cli_args.l0
Module: cli_args
Source: compiler/stage2_l0/src/cli_args.l0 Language: Dea/L0
Imports / Includes
build_infoutil.diagstd.vectorstd.textstd.stringstd.io
Symbols
- CliMode
- cli_options_create
- cli_options_free
- cli_options_free_opt
- cli_diag_free_opt
- cli_parse_result_free
- cli_emit_error
- cli_emit_reserved_option_error
- cli_has_diagnostic_code
- cli_compiler_identity_text
- cli_mode_flag
- cli_mode_name
- cli_try_set_mode
- cli_split_index
- cli_has_help_flag
- cli_has_version_flag
- cli_print_line
- cli_print_blank_line
- cli_print_usage
- cli_print_help
- cli_print_version
- cli_verbose_cluster_count
- cli_require_next_value
- cli_assign_target
- cli_validate_mode_scoped_flags
- cli_parse
- CliOptions
- CliParseResult
Enum CliMode
CliMode
Defines the CliMode enumeration.
Variants:
CM_RUNCM_BUILDCM_COMPILECM_GENCM_CHECKCM_TOKCM_ASTCM_SYMCM_TYPE
Function cli_options_create
func cli_options_create() -> CliOptions*
Create a CliOptions instance with default values.
Returns: New CLI options object.
Function cli_options_free
func cli_options_free(self: CliOptions*)
Free a CliOptions instance.
Parameters:
self: CLI options to free.
Function cli_options_free_opt
func cli_options_free_opt(self: CliOptions*?)
Free a nullable CliOptions instance when present.
Parameters:
self: Optional CLI options to free.
Function cli_diag_free_opt
func cli_diag_free_opt(self: DiagCollector*?)
Free a nullable diagnostic collector when present.
Parameters:
self: Optional diagnostic collector to free.
Function cli_parse_result_free
func cli_parse_result_free(self: CliParseResult*)
Free a CLI parse result and any owned options.
Parameters:
self: Parse result to free.
Function cli_emit_error
func cli_emit_error(diags: DiagCollector*, code: string, message: string)
Emit a command-line diagnostic without source coordinates.
Parameters:
diags: Diagnostic collector.code: Diagnostic code.message: Diagnostic message.
Function cli_emit_reserved_option_error
func cli_emit_reserved_option_error(diags: DiagCollector*, option: string, purpose: string)
Emit the standard diagnostic for a recognized canonical option whose behavior is not implemented yet.
Parameters:
diags: Diagnostic collector.option: Canonical short option.purpose: Reserved option purpose.
Function cli_has_diagnostic_code
func cli_has_diagnostic_code(diags: DiagCollector*, code: string) -> bool
Return whether a diagnostic collector contains one diagnostic code.
Parameters:
diags: Diagnostic collector to inspect.code: Diagnostic code to find.
Returns: true when the code is present.
Function cli_compiler_identity_text
func cli_compiler_identity_text() -> string
Return the user-facing compiler identity/version text.
Returns: Stable compiler identity text for help and --version.
Function cli_mode_flag
func cli_mode_flag(mode: CliMode) -> string
Return the canonical long flag for a CLI mode.
Parameters:
mode: CLI mode to format.
Returns: Long-form flag such as --check.
Function cli_mode_name
func cli_mode_name(mode: CliMode) -> string
Return the short display name for a CLI mode.
Parameters:
mode: CLI mode to format.
Returns: Short mode name such as check.
Function cli_try_set_mode
func cli_try_set_mode(opts: CliOptions*, diags: DiagCollector*, mode: CliMode)
Set the active CLI mode or emit an error for conflicting mode flags.
Parameters:
opts: Parsed CLI options.diags: Diagnostic collector.mode: Mode requested by the current flag.
Function cli_split_index
func cli_split_index(argv: StringVector*) -> int
Return the index of the -- argument separator.
Parameters:
argv: Full argument vector.
Returns: Separator index, or -1 if -- is not present.
Function cli_has_help_flag
func cli_has_help_flag(argv: StringVector*, cli_end: int) -> bool
Report whether the compiler CLI args explicitly request help output.
Only tokens before the -- separator count as compiler CLI arguments.
Parameters:
argv: Full argument vector excluding the executable name.cli_end: Exclusive end index for compiler CLI arguments.
Returns: true when -h or --help is present before cli_end.
Function cli_has_version_flag
func cli_has_version_flag(argv: StringVector*, cli_end: int) -> bool
Report whether the compiler CLI args explicitly request version output.
Only tokens before the -- separator count as compiler CLI arguments.
Parameters:
argv: Full argument vector excluding the executable name.cli_end: Exclusive end index for compiler CLI arguments.
Returns: true when -V or --version is present before cli_end.
Function cli_print_line
func cli_print_line(to_stderr: bool, text: string)
Print one CLI help/usage line to standard output or standard error.
Parameters:
to_stderr: Whether the text should be written to standard error.text: Line text without a trailing newline.
Function cli_print_blank_line
func cli_print_blank_line(to_stderr: bool)
Print a blank line to standard output or standard error.
Parameters:
to_stderr: Whether the newline should be written to standard error.
Function cli_print_usage
func cli_print_usage(to_stderr: bool)
Print the short Stage 2 usage banner.
Parameters:
to_stderr: Whether the banner should be written to standard error.
Function cli_print_help
func cli_print_help()
Print the full Stage 2 help text.
Function cli_print_version
func cli_print_version()
Print the compiler identity/version text.
Function cli_verbose_cluster_count
func cli_verbose_cluster_count(token: string) -> int
Count verbosity flags in a short option cluster.
Parameters:
token: Argument token to inspect.
Returns: Number of v characters in a token like -vvv, or -1 if the token is not such a cluster.
Function cli_require_next_value
func cli_require_next_value(argv: StringVector*, i: int, option: string, diags: DiagCollector*) -> string?
Return the value following an option that requires one.
Parameters:
argv: Full argument vector.i: Index of the option token.option: Exact option token used in diagnostics.diags: Diagnostic collector.
Returns: Following argument value, or null after emitting a missing-value error.
Function cli_assign_target
func cli_assign_target(opts: CliOptions*, token: string)
Assign a positional target argument.
Parameters:
opts: Parsed CLI options.token: Positional argument to record.
Function cli_validate_mode_scoped_flags
func cli_validate_mode_scoped_flags(opts: CliOptions*, diags: DiagCollector*)
Validate that mode-specific flags are used with compatible modes.
Parameters:
opts: Parsed CLI options.diags: Diagnostic collector for incompatibility errors.
Function cli_parse
func cli_parse(argv: StringVector*) -> CliParseResult*
Parse command-line arguments into structured options.
Parameters:
argv: Argument vector excluding the executable name.
Returns: Parsed options together with any diagnostics produced during parsing.
Struct CliOptions
Represents the CliOptions structure.
CliOptions Field mode
mode: CliMode
CliOptions Field mode_explicit
mode_explicit: bool
CliOptions Field verbosity
verbosity: int
CliOptions Field log
log: bool
CliOptions Field project_roots
project_roots: StringVector*
CliOptions Field sys_roots
sys_roots: StringVector*
CliOptions Field interface_paths
interface_paths: StringVector*
CliOptions Field output
output: string?
CliOptions Field keep_c
keep_c: bool
CliOptions Field c_compiler
c_compiler: string?
CliOptions Field c_options
c_options: string?
CliOptions Field c_sources
c_sources: StringVector*
CliOptions Field runtime_include
runtime_include: string?
CliOptions Field runtime_lib
runtime_lib: string?
CliOptions Field no_line_directives
no_line_directives: bool
CliOptions Field trace_arc
trace_arc: bool
CliOptions Field trace_memory
trace_memory: bool
CliOptions Field unchecked
unchecked: bool
CliOptions Field check_basic
check_basic: bool
CliOptions Field all_modules
all_modules: bool
CliOptions Field include_eof
include_eof: bool
CliOptions Field entry_target
entry_target: string?
CliOptions Field extra_target_count
extra_target_count: int
CliOptions Field program_args
program_args: StringVector*
Struct CliParseResult
Represents the CliParseResult structure.
CliParseResult Field options
options: CliOptions*?
CliParseResult Field diags
diags: DiagCollector*
CliParseResult Field help_requested
help_requested: bool
CliParseResult Field version_requested
version_requested: bool
CliParseResult Field verbosity
verbosity: int
CliParseResult Field rich_log
rich_log: bool