aboutsummaryrefslogtreecommitdiff
path: root/mingling/src/constants
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-19 00:22:23 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-19 00:27:16 +0800
commit5e460470f6ea2ce31a403b6e936ec2fe8f45312a (patch)
treeec1d675d9544b31ab9382ebbd10bbeda43923cc8 /mingling/src/constants
parent9b4cffd48482481691f782e74a4726294043bc57 (diff)
feat: migrate mingling-specific picker code into mingling crate
BREAKING CHANGE: Remove `mingling_support` feature from arg-picker crate. The `EntryPicker` trait and `corebind` module are now part of the mingling crate directly, and `build_pattern1` is now a public method.
Diffstat (limited to 'mingling/src/constants')
-rw-r--r--mingling/src/constants/exit_codes.rs14
-rw-r--r--mingling/src/constants/picker.rs129
2 files changed, 143 insertions, 0 deletions
diff --git a/mingling/src/constants/exit_codes.rs b/mingling/src/constants/exit_codes.rs
new file mode 100644
index 0000000..2359f42
--- /dev/null
+++ b/mingling/src/constants/exit_codes.rs
@@ -0,0 +1,14 @@
+/// Exit code indicating successful command execution.
+pub const EXIT_SUCCESS: i32 = 0;
+
+/// Exit code for general errors.
+pub const EXIT_GENERAL_ERR: i32 = 1;
+
+/// Exit code for incorrect command usage (or invalid arguments).
+pub const EXIT_USAGE_ERR: i32 = 2;
+
+/// Exit code indicating permission denied (or the command is not executable).
+pub const EXIT_PERM_DENIED: i32 = 126;
+
+/// Exit code for command not found (or PATH error).
+pub const EXIT_CMD_NOT_FOUND: i32 = 127;
diff --git a/mingling/src/constants/picker.rs b/mingling/src/constants/picker.rs
new file mode 100644
index 0000000..f2a448b
--- /dev/null
+++ b/mingling/src/constants/picker.rs
@@ -0,0 +1,129 @@
+use std::marker::PhantomData;
+
+use arg_picker::{PickerArg, PickerArgs, value::Flag};
+
+/// Remaining positional arguments (anything not consumed as an option).
+/// - `full`: `[]` (empty — not triggered by any `--` prefix).
+/// - `short`: (none)
+/// - `positional`: `false` (this is a meta‑argument that collects everything left).
+/// This constant is used internally to access any leftover arguments after
+/// all defined flags/options have been processed.
+pub const REMAINS: PickerArg<PickerArgs> = PickerArg::<PickerArgs> {
+ full: &[],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// Help flag: display usage information.
+/// - `full`: `["help"]`
+/// - `short`: `'h'`
+pub const HELP_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["help"],
+ short: Some('h'),
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// Quiet flag: suppress output.
+/// - `full`: `["quiet"]`
+/// - `short`: `'q'`
+pub const QUIET_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["quiet"],
+ short: Some('q'),
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// Confirm flag: require user confirmation before proceeding.
+/// - `full`: `["confirm"]`
+/// - `short`: `'C'`
+pub const CONFIRM_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["confirm"],
+ short: Some('C'),
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// Renderer flag: explicitly specify the Structural Renderer argument.
+/// - `full`: `["renderer"]`
+/// - `short`: (none)
+#[cfg(feature = "structural_renderer")]
+pub const RENDERER_ARG: PickerArg<String> = PickerArg::<String> {
+ full: &["renderer"],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// JSON flag: enable JSON output format.
+/// - `full`: `["json"]`
+/// - `short`: (none)
+/// Available only when the `json_serde_fmt` feature is enabled.
+#[cfg(feature = "json_serde_fmt")]
+pub const JSON_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["json"],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// JSON pretty flag: enable pretty-printed JSON output format.
+/// - `full`: `["json_pretty"]`
+/// - `short`: (none)
+/// Available only when the `json_serde_fmt` feature is enabled.
+#[cfg(feature = "json_serde_fmt")]
+pub const JSON_PRETTY_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["json_pretty"],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// YAML flag: enable YAML output format.
+/// - `full`: `["yaml"]`
+/// - `short`: (none)
+/// Available only when the `yaml_serde_fmt` feature is enabled.
+#[cfg(feature = "yaml_serde_fmt")]
+pub const YAML_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["yaml"],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// TOML flag: enable TOML output format.
+/// - `full`: `["toml"]`
+/// - `short`: (none)
+/// Available only when the `toml_serde_fmt` feature is enabled.
+#[cfg(feature = "toml_serde_fmt")]
+pub const TOML_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["toml"],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// RON flag: enable RON output format.
+/// - `full`: `["ron"]`
+/// - `short`: (none)
+/// Available only when the `ron_serde_fmt` feature is enabled.
+#[cfg(feature = "ron_serde_fmt")]
+pub const RON_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["ron"],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
+
+/// RON pretty flag: enable pretty-printed RON output format.
+/// - `full`: `["ron_pretty"]`
+/// - `short`: (none)
+/// Available only when the `ron_serde_fmt` feature is enabled.
+#[cfg(feature = "ron_serde_fmt")]
+pub const RON_PRETTY_FLAG: PickerArg<Flag> = PickerArg::<Flag> {
+ full: &["ron_pretty"],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};