Repository: clap-rs/clap
Pull request #2030 (2020-07-20 23:48:44)

style: replacing yml with yaml for consistency
Replaces all occurrences of .yml and yml in code by .yaml and yaml (reviewed, no occurrences of YML, except inside of words).

As discussed [here](https://github.com/clap-rs/clap/discussions/2017), there is an official recommendation of using `.yaml` extension instead of `.yml`.

Now `yaml` is consistent in the whole project.

marcospb19: I forgot to rename some files.

Patch:
diff --git a/README.md b/README.md
index b9732cd9..a22b416a 100644
--- a/README.md
+++ b/README.md
@@ -275,7 +275,7 @@ fn main() {
 This third method shows how you can use a YAML file to build your CLI and keep your Rust source tidy
 or support multiple localized translations by having different YAML files for each localization.
 
-First, create the `cli.yml` file to hold your CLI options, but it could be called anything we like:
+First, create the `cli.yaml` file to hold your CLI options, but it could be called anything we like:
 
 ```yaml
 name: myapp
@@ -328,7 +328,7 @@ use clap::{App, load_yaml};
 
 fn main() {
     // The YAML file is found relative to the current file, similar to how modules are found
-    let yaml = load_yaml!("cli.yml");
+    let yaml = load_yaml!("cli.yaml");
     let matches = App::from(yaml).get_matches();
 
     // Same as previous examples...
diff --git a/clap_derive/README.md b/clap_derive/README.md
index ed3c3be4..9c289b36 100644
--- a/clap_derive/README.md
+++ b/clap_derive/README.md
@@ -133,7 +133,7 @@ Opt {
 
 ## clap_derive rustc version policy
 
-- Minimum rustc version modification must be specified in the [changelog](https://github.com/clap-rs/clap_derive/blob/master/CHANGELOG.md) and in the [travis configuration](https://github.com/clap-rs/clap_derive/blob/master/.travis.yml).
+- Minimum rustc version modification must be specified in the [changelog](https://github.com/clap-rs/clap_derive/blob/master/CHANGELOG.md) and in the [travis configuration](https://github.com/clap-rs/clap_derive/blob/master/.travis.yaml).
 - Contributors can increment minimum rustc version without any justification if the new version is required by the latest version of one of clap_derive's depedencies (`cargo update` will not fail on clap_derive).
 - Contributors can increment minimum rustc version if the library user experience is improved.
 
diff --git a/examples/17_yaml.rs b/examples/17_yaml.rs
index 90232ebc..ac0f92b4 100644
--- a/examples/17_yaml.rs
+++ b/examples/17_yaml.rs
@@ -18,7 +18,7 @@
 fn main() {
     use clap::{load_yaml, App};
 
-    // To load a yaml file containing our CLI definition such as the example '17_yaml.yml' we can
+    // To load a yaml file containing our CLI definition such as the example '17_yaml.yaml' we can
     // use the convenience macro which loads the file at compile relative to the current file
     // similar to how modules are found.
     //
@@ -26,10 +26,10 @@ fn main() {
     //
     // Finally we call get_matches() to start the parsing process. We use the matches just as we
     // normally would
-    let yml = load_yaml!("17_yaml.yml");
-    let m = App::from(yml).get_matches();
+    let yaml = load_yaml!("17_yaml.yaml");
+    let m = App::from(yaml).get_matches();
 
-    // Because the example 17_yaml.yml is rather large we'll just look a single arg so you can
+    // Because the example 17_yaml.yaml is rather large we'll just look a single arg so you can
     // see that it works...
     if let Some(mode) = m.value_of("mode") {
         match mode {
diff --git a/examples/17_yaml.yml b/examples/17_yaml.yaml
similarity index 97%
rename from examples/17_yaml.yml
rename to examples/17_yaml.yaml
index 5f8eb89c..9d08a1bc 100644
--- a/examples/17_yaml.yml
+++ b/examples/17_yaml.yaml
@@ -1,6 +1,6 @@
-name: yml_app
+name: yaml_app
 version: "1.0"
-about: an example using a .yml file to build a CLI
+about: an example using a .yaml file to build a CLI
 author: Kevin K. <kbknapp@gmail.com>
 
 # AppSettings can be defined as a list and are **not** ascii case sensitive
diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs
index 266faedd..5e34f42c 100644
--- a/src/build/app/mod.rs
+++ b/src/build/app/mod.rs
@@ -388,8 +388,8 @@ impl<'b> App<'b> {
     /// # Examples
     /// ```ignore
     /// # use clap::{App, load_yaml};
-    /// let yml = load_yaml!("app.yml");
-    /// let app = App::from(yml)
+    /// let yaml = load_yaml!("app.yaml");
+    /// let app = App::from(yaml)
     ///     .name(crate_name!());
     ///
     /// // continued logic goes here, such as `app.get_matches()` etc.
diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs
index a799597c..f9e2ea67 100644
--- a/src/build/arg/mod.rs
+++ b/src/build/arg/mod.rs
@@ -4185,24 +4185,24 @@ impl<'a> Arg<'a> {
 
 #[cfg(feature = "yaml")]
 impl<'a> From<&'a Yaml> for Arg<'a> {
-    /// Creates a new instance of [`Arg`] from a .yml (YAML) file.
+    /// Creates a new instance of [`Arg`] from a .yaml (YAML) file.
     ///
     /// # Examples
     ///
     /// ```ignore
     /// use clap::{Arg, load_yaml};
-    /// let yml = load_yaml!("arg.yml");
-    /// let arg = Arg::from(yml);
+    /// let yaml = load_yaml!("arg.yaml");
+    /// let arg = Arg::from(yaml);
     /// ```
     /// [`Arg`]: ./struct.Arg.html
     #[allow(clippy::cognitive_complexity)]
     fn from(y: &'a Yaml) -> Self {
         let y = y.as_hash().unwrap();
         // We WANT this to panic on error...so expect() is good.
-        let name_yml = y.keys().next().unwrap();
-        let name_str = name_yml.as_str().unwrap();
+        let name_yaml = y.keys().next().unwrap();
+        let name_str = name_yaml.as_str().unwrap();
         let mut a = Arg::new(name_str);
-        let arg_settings = y.get(name_yml).unwrap().as_hash().unwrap();
+        let arg_settings = y.get(name_yaml).unwrap().as_hash().unwrap();
 
         for (k, v) in arg_settings.iter() {
             a = match k.as_str().unwrap() {
diff --git a/src/build/arg_group.rs b/src/build/arg_group.rs
index 66d98d01..7a1e9204 100644
--- a/src/build/arg_group.rs
+++ b/src/build/arg_group.rs
@@ -411,26 +411,26 @@ impl<'a, 'z> From<&'z ArgGroup<'a>> for ArgGroup<'a> {
 
 #[cfg(feature = "yaml")]
 impl<'a> From<&'a Yaml> for ArgGroup<'a> {
-    /// Creates a new instance of `ArgGroup` from a .yml (YAML) file.
+    /// Creates a new instance of `ArgGroup` from a .yaml (YAML) file.
     ///
     /// # Examples
     ///
     /// ```ignore
     /// # use clap::{ArgGroup, load_yaml};
-    /// let yml = load_yaml!("group.yml");
-    /// let ag = ArgGroup::from(yml);
+    /// let yaml = load_yaml!("group.yaml");
+    /// let ag = ArgGroup::from(yaml);
     /// ```
     fn from(y: &'a Yaml) -> Self {
         let b = y.as_hash().expect("ArgGroup::from::<Yaml> expects a table");
         // We WANT this to panic on error...so expect() is good.
         let mut a = ArgGroup::default();
         let group_settings = if b.len() == 1 {
-            let name_yml = b.keys().next().expect("failed to get name");
-            let name_str = name_yml
+            let name_yaml = b.keys().next().expect("failed to get name");
+            let name_str = name_yaml
                 .as_str()
                 .expect("failed to convert arg YAML name to str");
             a.name = name_str;
-            b.get(name_yml)
+            b.get(name_yaml)
                 .expect("failed to get name_str")
                 .as_hash()
                 .expect("failed to convert to a hash")
@@ -541,8 +541,8 @@ requires:
 - r2
 - r3
 - r4";
-        let yml = &YamlLoader::load_from_str(g_yaml).expect("failed to load YAML file")[0];
-        let g = ArgGroup::from(yml);
+        let yaml = &YamlLoader::load_from_str(g_yaml).expect("failed to load YAML file")[0];
+        let g = ArgGroup::from(yaml);
         let args = vec!["a1".into(), "a4".into(), "a2".into(), "a3".into()];
         let reqs = vec!["r1".into(), "r2".into(), "r3".into(), "r4".into()];
         let confs = vec!["c1".into(), "c2".into(), "c3".into(), "c4".into()];
diff --git a/src/macros.rs b/src/macros.rs
index 54e6e293..a0818980 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -17,8 +17,8 @@
 /// # extern crate clap;
 /// # use clap::App;
 /// # fn main() {
-/// let yml = load_yaml!("app.yml");
-/// let app = App::from(yml);
+/// let yaml = load_yaml!("app.yaml");
+/// let app = App::from(yaml);
 ///
 /// // continued logic goes here, such as `app.get_matches()` etc.
 /// # }
@@ -26,8 +26,9 @@
 #[cfg(feature = "yaml")]
 #[macro_export]
 macro_rules! load_yaml {
-    ($yml:expr) => {
-        &$crate::YamlLoader::load_from_str(include_str!($yml)).expect("failed to load YAML file")[0]
+    ($yaml:expr) => {
+        &$crate::YamlLoader::load_from_str(include_str!($yaml)).expect("failed to load YAML file")
+            [0]
     };
 }
 


Test patch:
diff --git a/tests/fixtures/app.yml b/tests/fixtures/app.yaml
similarity index 100%
rename from tests/fixtures/app.yml
rename to tests/fixtures/app.yaml
diff --git a/tests/fixtures/app_2space.yml b/tests/fixtures/app_2space.yaml
similarity index 100%
rename from tests/fixtures/app_2space.yml
rename to tests/fixtures/app_2space.yaml
diff --git a/tests/yaml.rs b/tests/yaml.rs
index 2852948e..d19a3efc 100644
--- a/tests/yaml.rs
+++ b/tests/yaml.rs
@@ -4,21 +4,21 @@ use clap::{load_yaml, App};
 
 #[test]
 fn create_app_from_yaml() {
-    let yml = load_yaml!("fixtures/app.yml");
-    App::from(yml);
+    let yaml = load_yaml!("fixtures/app.yaml");
+    App::from(yaml);
 }
 
 // TODO: Uncomment to test yaml with 2 spaces https://github.com/chyh1990/yaml-rust/issues/101
 // #[test]
 // fn create_app_from_yaml_2spaces() {
-//     let yml = load_yaml!("fixtures/app_2space.yml");
-//     App::from(yml);
+//     let yaml = load_yaml!("fixtures/app_2space.yaml");
+//     App::from(yaml);
 // }
 
 #[test]
 fn help_message() {
-    let yml = load_yaml!("fixtures/app.yml");
-    let mut app = App::from(yml);
+    let yaml = load_yaml!("fixtures/app.yaml");
+    let mut app = App::from(yaml);
     // Generate the full help message!
     let _ = app.try_get_matches_from_mut(Vec::<String>::new());
 
@@ -31,8 +31,8 @@ fn help_message() {
 
 #[test]
 fn author() {
-    let yml = load_yaml!("fixtures/app.yml");
-    let mut app = App::from(yml);
+    let yaml = load_yaml!("fixtures/app.yaml");
+    let mut app = App::from(yaml);
     // Generate the full help message!
     let _ = app.try_get_matches_from_mut(Vec::<String>::new());