pub struct Context {
pub raw_args: Vec<String>,
pub args: VecDeque<String>,
pub common_flags: Vector<Vector<Flag>>,
pub routes: Vector<String>,
pub exe_path: String,
pub common_flags_values: Vector<(String, FlagValue)>,
pub local_flags_values: Vector<(String, FlagValue)>,
pub parsing_args: Option<VecDeque<MiddleArg>>,
pub error_info_list: Vector<ErrorInfo>,
}
Expand description
Storage information for command execution. This storage raw args, non-flag args, flag values, and etc. コマンドからrunを通ってactionにたどり着くまでの情報およびパース結果を格納する構造体。 フラグの値、たどってきたルートなどを保管。
Fields
raw_args: Vec<String>
raw args
args: VecDeque<String>
non-flag args
common_flags: Vector<Vector<Flag>>
common_flags of its own and inherited
routes: Vector<String>
routes of from root to end
exe_path: String
exe_path (String, not PathBuf)
common_flags_values: Vector<(String, FlagValue)>
storage of result of parsing common flags values
local_flags_values: Vector<(String, FlagValue)>
storage of result of parsing local flags values
parsing_args: Option<VecDeque<MiddleArg>>
On parsing, storage of parsing args. In edge(action), storage of error args
error_info_list: Vector<ErrorInfo>
error inforamation list of parsing
Implementations
sourceimpl Context
impl Context
sourcepub fn new(
raw_args: Vec<String>,
args: VecDeque<String>,
common_flags: Vector<Flag>,
routes: Vector<String>,
exe_path: String
) -> Context
pub fn new(
raw_args: Vec<String>,
args: VecDeque<String>,
common_flags: Vector<Flag>,
routes: Vector<String>,
exe_path: String
) -> Context
Creates a new instance of Context
sourcepub fn with_all_field(
raw_args: Vec<String>,
args: VecDeque<String>,
common_flags: Vector<Vector<Flag>>,
exe_path: String,
routes: Vector<String>,
common_flags_values: Vector<(String, FlagValue)>,
local_flags_values: Vector<(String, FlagValue)>,
parsing_args: Option<VecDeque<MiddleArg>>,
error_info_list: Vector<ErrorInfo>
) -> Context
pub fn with_all_field(
raw_args: Vec<String>,
args: VecDeque<String>,
common_flags: Vector<Vector<Flag>>,
exe_path: String,
routes: Vector<String>,
common_flags_values: Vector<(String, FlagValue)>,
local_flags_values: Vector<(String, FlagValue)>,
parsing_args: Option<VecDeque<MiddleArg>>,
error_info_list: Vector<ErrorInfo>
) -> Context
Creates a new instance of Context with all options.
sourcepub fn change_exe_path(self, path: String)
pub fn change_exe_path(self, path: String)
Change exe_path’s value
sourcepub fn push_back_to_parsing_args(&mut self, middle_arg: MiddleArg)
pub fn push_back_to_parsing_args(&mut self, middle_arg: MiddleArg)
Add(Push back) middle_arg to this context’s parsing_args
sourcepub fn push_front_to_parsing_args(&mut self, middle_arg: MiddleArg)
pub fn push_front_to_parsing_args(&mut self, middle_arg: MiddleArg)
Shift(Push front) middle_arg to this context’s parsing_args
sourcepub fn take_flag_value_of(
&mut self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
pub fn take_flag_value_of(
&mut self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
Takes flag value from context. Different from get, returns flag_value instance own (not reference) that has context. contextからフラグ値を取得する。Getとは違い、参照ではなくcontextに格納されているもの(格納されていない場合はデフォルト値のコピー)そのものを返す
sourcepub fn take_inputted_flag_value_of(
&mut self,
flag_name: &str
) -> Option<FlagValue>
pub fn take_inputted_flag_value_of(
&mut self,
flag_name: &str
) -> Option<FlagValue>
Takes inputted flag value from context. Different from get, returns flag_value instance own (not reference) that has context. contextからフラグ値を(ユーザによりargに指定(入力)されている場合)取得する。Getとは違い、参照ではなくcontextに格納されているもの(格納されていない場合はNoneを)そのものを返す
sourcepub fn take_local_flag_value_of(
&mut self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
pub fn take_local_flag_value_of(
&mut self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
Takes flag value from context. Different from get, returns flag_value instance own (not reference) that has context. contextからローカルフラグの値を取得する。Getとは違い、参照ではなくcontextに格納されているもの(格納されていない場合はデフォルト値のコピー)そのものを返す
sourcepub fn take_common_flag_value_of(
&mut self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
pub fn take_common_flag_value_of(
&mut self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
Takes inputted flag value from context. Different from get, returns flag_value instance own (not reference) that has context. contextからコモンフラグの値を取得する。Getとは違い、参照ではなくcontextに格納されているもの(格納されていない場合はデフォルト値のコピー)そのものを返す
sourcepub fn take_inputted_local_flag_value_of(
&mut self,
flag_name: &str
) -> Option<FlagValue>
pub fn take_inputted_local_flag_value_of(
&mut self,
flag_name: &str
) -> Option<FlagValue>
Takes inputted local flag value from context. Different from get, returns flag_value instance own (not reference) that has context. contextからローカルフラグ値を(ユーザによりargに指定(入力)されている場合)取得する。Getとは違い、参照ではなくcontextに格納されているものそのもの(格納されていない場合はNone)を返す
sourcepub fn take_inputted_common_flag_value_of(
&mut self,
flag_name: &str
) -> Option<FlagValue>
pub fn take_inputted_common_flag_value_of(
&mut self,
flag_name: &str
) -> Option<FlagValue>
Takes inputted local flag value from context. Different from get, returns flag_value instance own (not reference) that has context. contextからコモンフラグ値を(ユーザによりargに指定(入力)されている場合)取得する。Getとは違い、参照ではなくcontextに格納されているものそのもの(格納されていない場合はNone)を返す
sourcepub fn get_flag_value_of(
&self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
pub fn get_flag_value_of(
&self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
Gets FlagValue’s clone of the flag matches flag_name from context. contextからフラグ値のcloneを取得する。フラグが設定されていない場合はNoneを返す なお明示的に値が指定されない場合、Bool型のフラグであればFlagValue::Bool(true)とし、String型のフラグであればFlagValue::String(String::new())、それ以外の型のフラグではFlagValue::NoneをSomeで包んで返す
sourcepub fn get_inputted_flag_value_of(&self, flag_name: &str) -> Option<FlagValue>
pub fn get_inputted_flag_value_of(&self, flag_name: &str) -> Option<FlagValue>
Gets FlagValue’s clone of the inputted flag matches flag_name from context. contextからユーザから指定された場合のフラグ値のcloneを取得する。ユーザから入力されていない場合はNoneを返す。
sourcepub fn get_common_flag_value_of(
&self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
pub fn get_common_flag_value_of(
&self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
Gets FlagValue’s clone of the common flag matches flag_name from context. If it is not defined, Returns None. contextからユーザから指定された場合のコモンフラグ値のcloneを取得する。ユーザから入力されていないが定義されている場合はデフォルト値のクローンを返す。定義もされていない場合はNoneを返す。 なお明示的に値が指定されない場合、Bool型のフラグであればFlagValue::Bool(true)とし、String型のフラグであればFlagValue::String(String::new())、それ以外の型のフラグではFlagValue::NoneをSomeで包んで返す
sourcepub fn get_local_flag_value_of(
&self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
pub fn get_local_flag_value_of(
&self,
flag_name: &str,
current_command: &Command
) -> Option<FlagValue>
Gets FlagValue’s clone of the common flag matches flag_name from context. If it is not defined, Returns None. contextからユーザから指定された場合のローカルフラグ値のcloneを取得する。ユーザから入力されていないが定義されている場合はデフォルト値のクローンを返す。定義もされていない場合はNoneを返す。 なお明示的に値が指定されない場合、Bool型のフラグであればFlagValue::Bool(true)とし、String型のフラグであればFlagValue::String(String::new())、それ以外の型のフラグではFlagValue::NoneをSomeで包んで返す
sourcepub fn get_inputted_local_flag_value_of(
&self,
flag_name: &str
) -> Option<FlagValue>
pub fn get_inputted_local_flag_value_of(
&self,
flag_name: &str
) -> Option<FlagValue>
Gets the flag value of the local flag matches flag_name if inputted. If it is not defined or not inputted, returns None. flag_nameとnameが一致するローカルフラグがあり、それがユーザからコマンド引数で指定されていた場合、その値のクローンをSomeで包んで返す。flag_nameと一致するnameをどのローカルフラグも持たないか、ユーザがコマンド引数で指定していない場合はNoneを返す。
sourcepub fn get_inputted_common_flag_value_of(
&self,
flag_name: &str
) -> Option<FlagValue>
pub fn get_inputted_common_flag_value_of(
&self,
flag_name: &str
) -> Option<FlagValue>
Gets the flag value of the common flag whose name matches flag_name. If it is not defined or not inputted, returns None. flag_nameとnameが一致するコモンフラグがあり、それがユーザからコマンド引数で指定されていた場合、その値のクローンをSomeで包んで返す。flag_nameと一致するnameをどのコモンフラグも持たないか、ユーザがコマンド引数で指定していない場合はNoneを返す。
sourcepub fn is_flag_true(&self, name: &str, current_command: &Command) -> bool
pub fn is_flag_true(&self, name: &str, current_command: &Command) -> bool
Returns flag has specified name is true flag.
Trait Implementations
sourceimpl Run<Context> for Command
impl Run<Context> for Command
sourcefn run(self, c: Context) -> Result<ActionResult, ActionError>
fn run(self, c: Context) -> Result<ActionResult, ActionError>
run function
Auto Trait Implementations
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more