diff options
Diffstat (limited to 'mingling_core/src/comp/comp_ctx.rs')
| -rw-r--r-- | mingling_core/src/comp/comp_ctx.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/mingling_core/src/comp/comp_ctx.rs b/mingling_core/src/comp/comp_ctx.rs index f2b83e6..04ef853 100644 --- a/mingling_core/src/comp/comp_ctx.rs +++ b/mingling_core/src/comp/comp_ctx.rs @@ -1,4 +1,3 @@ -// Doc Not Optimize use crate::{COMPLETION_SUBCOMMAND, Program, ProgramCollect}; impl<C> Program<C> @@ -11,6 +10,25 @@ where /// (defined by [`COMPLETION_SUBCOMMAND`]) appears among the parsed arguments. /// When `true`, the program should generate shell completions instead of /// running its normal execution path. + /// + /// # Returns + /// + /// `true` if the program is in completion mode, `false` otherwise. + /// + /// # Example + /// + /// ``` + /// # #[cfg(feature = "comp")] { + /// # use mingling_core::MockProgramCollect as ThisProgram; + /// use mingling_core::Program; + /// + /// let completing = Program::<ThisProgram>::new_with_args(["my_prog", "__comp"]).is_completing(); + /// assert!(completing); + /// + /// let not_completing = Program::<ThisProgram>::new_with_args(["my_prog", "run"]).is_completing(); + /// assert!(!not_completing); + /// # } + /// ``` #[must_use] pub fn is_completing(&self) -> bool { // Check if the first argument (args[1]) is the completion subcommand |
