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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
/// # Config Reference /// /// Config file reference for `a_cli_tool`. /// /// By default `a_cli_tool` looks for configuration in `./config.yaml`, /// unless another path is specified with the `-c/--config` parameter. /// /// `Config` details the structure of the configuration. /// #[derive(serde::Deserialize, schemars::JsonSchema)] pub struct Config { /// The name of the thing this CLI tool is building for you. /// name: String, /// The version of the thing this CLI tool will build for you. /// /// This is a [SemVer][semver] version, e.g: /// /// ```yaml /// version: 1.2.3 /// ``` /// /// [semver]: https://semver.org/ /// version: String, /// _Optional:_ A description of the thing this CLI tool is /// building for you. /// description: Option<String>, #[serde(flatten)] data: AppData, } /// Application config fields. /// /// Configuration for this CLI tool that tell it where to get data /// from, write data to, and what operations to perform on it. /// #[derive(serde::Deserialize, schemars::JsonSchema)] pub struct AppData { /// The configuration for the source of data for this tool. /// source: Source, /// A path to write the created thing to. /// target: std::path::PathBuf, /// The operations to perform on the data this tool manipulates. /// /// This array of operations will be performed in order and an /// operation may appear more than once. /// /// E.g: /// /// ```yaml /// actions: [ foo, bar, baz, bar ] /// ``` /// actions: Vec<Actions>, } /// The configuration for the source of data for this tool. /// /// This can either be set to a local file: /// /// ```yaml /// source: /// file: path/to/file.yaml /// ``` /// /// Or a URL: /// /// ```yaml /// source: /// url: https://urlofsource.com/sourcedata/ /// ``` /// /// --- /// /// Back to: /// /// - [App Configuration](./struct.AppData.html#structfield.source) /// - [Configuration Reference](./struct.Config.html#structfield.data) /// #[derive(serde::Deserialize, schemars::JsonSchema)] #[serde(rename_all = "snake_case")] pub enum Source { File(std::path::PathBuf), Url(String), } /// The possible operations to perform on the data this tool manipulates. /// /// See each option below for what it does and how it's referenced in /// config. /// #[derive(serde::Deserialize, schemars::JsonSchema)] #[serde(rename_all = "snake_case")] pub enum Actions { /// Perform a "foo" operation on the data: /// /// ```yaml /// foo /// ``` Foo, /// Perform a "bar" operation on the data: /// /// ```yaml /// bar /// ``` Bar, /// Perform a "baz" operation on the data: /// /// ```yaml /// baz /// ``` Baz, /// Perform a "foo bar" operation on the data: /// /// ```yaml /// foo_bar /// ``` FooBar, /// Perform a "foo baz" operation on the data: /// /// ```yaml /// foo_baz /// ``` BarBaz, /// Perform a "foo bar baz" operation on the data: /// /// ```yaml /// fbb /// ``` #[serde(rename = "fbb")] FooBarBaz, }