1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
/*! These actions are complete stand-alone entry points for the command-line tools. These may be invoked by other tools, however they may have side-effects such as writing to stdout. # Example The following is an example [`Action`](trait.action.html) implementation that does very little. To understand how to use existing actions, or create new ones, see the [User Guide](https://simonkjohnston.life/rust-mcfg/). ```rust use mcfg::actions::Action; use mcfg::error::Result; #[derive(Debug)] pub struct ExampleAction {} impl Action for ExampleAction { fn run(&self) -> Result<()> { println!("ListAction::run {:?}", self); Ok(()) } } impl ExampleAction { pub fn new() -> Result<Box<dyn Action>> { Ok(Box::from(ExampleAction {})) } } ``` */ use crate::error::Result; // ------------------------------------------------------------------------------------------------ // Public Types // ------------------------------------------------------------------------------------------------ /// /// Implemented by the actions exposed by the CLI. /// pub trait Action: Debug { /// Run this action, this assumes all information was passed to the action during creation. fn run(&self) -> Result<()>; } // ------------------------------------------------------------------------------------------------ // Modules // ------------------------------------------------------------------------------------------------ #[doc(hidden)] mod installers; pub use installers::EditInstallersAction; #[doc(hidden)] mod init; pub use init::InitAction; #[doc(hidden)] mod history; pub use history::HistoryAction; #[doc(hidden)] mod install; pub use install::InstallAction; #[doc(hidden)] mod list; pub use list::ListAction; #[doc(hidden)] mod manage; pub use manage::ManageAction; #[doc(hidden)] mod paths; pub use paths::ShowPathsAction; #[cfg(feature = "remove-self")] #[doc(hidden)] mod remove_self; #[cfg(feature = "remove-self")] pub use remove_self::RemoveSelfAction; #[doc(hidden)] mod refresh; pub use refresh::RefreshAction; #[doc(hidden)] mod shell; pub use shell::ShellAction; #[doc(hidden)] mod upgrade; use std::fmt::Debug; pub use upgrade::UpdateSelfAction;