Repository: ashleygwilliams/cargo-generate (rust)

Issue:
support for an additional placeholder for stating the current host architecture
support for an additional placeholder like `{{project-name}}` and/or `{{authors}}` containing the architecture of the host

Pull request description:
support operating system and architecture
support operating system and architecture as a placeholder, resolves #251 

Patch:
diff --git a/README.md b/README.md
index e607823..3663d71 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,7 @@ supported placeholders are:
 - `{{authors}}`: this will be filled in by a function borrowed from Cargo's source code, that determines your information from Cargo's configuration.
 - `{{project-name}}`: this is supplied by either passing the `--name` flag to the command or working with the interactive CLI to supply a name.
 - `{{crate_name}}`: the snake_case_version of `project-name`
+- `{{os-arch}}`: contains the current operating system and architecture ex: `linux-x86_64`
 
 Additionally all filters and tags of the liquid template language are supported. For more information, check out the [Liquid Documentation on `Tags` and `Filters`][liquid].
 
@@ -99,7 +100,7 @@ at your option.
 Unless you explicitly state otherwise, any contribution intentionally
 submitted for inclusion in the work by you, as defined in the Apache-2.0
 license, shall be dual licensed as above, without any additional terms or
-conditions.  
+conditions.
 If you want to contribute to `cargo-generate`, please read our [CONTRIBUTING notes].
 
 [CONTRIBUTING notes]: CONTRIBUTING.md
diff --git a/src/template.rs b/src/template.rs
index 19d02ff..6300092 100644
--- a/src/template.rs
+++ b/src/template.rs
@@ -8,6 +8,7 @@ use console::style;
 use heck::{CamelCase, KebabCase, SnakeCase};
 use indicatif::ProgressBar;
 use liquid_core::{Filter, FilterReflection, Object, ParseFilter, Runtime, ValueView};
+use std::env;
 use std::fs;
 use std::path::Path;
 use walkdir::{DirEntry, WalkDir};
@@ -105,11 +106,13 @@ impl Filter for SnakeCaseFilter {
 pub(crate) fn substitute(name: &ProjectName, force: bool) -> Result<Object> {
     let project_name = if force { name.raw() } else { name.kebab_case() };
     let authors = authors::get_authors()?;
+    let os_arch = format!("{}-{}", env::consts::OS, env::consts::ARCH);
 
     Ok(liquid::object!({
         "project-name": project_name,
         "crate_name": name.snake_case(),
         "authors": authors,
+        "os-arch": os_arch,
     }))
 }
 


Test patch:
diff --git a/tests/integration/basics.rs b/tests/integration/basics.rs
index fe477fe..96c2eea 100644
--- a/tests/integration/basics.rs
+++ b/tests/integration/basics.rs
@@ -4,6 +4,7 @@ use crate::helpers::project_builder::dir;
 
 use assert_cmd::prelude::*;
 use predicates::prelude::*;
+use std::env;
 use std::fs;
 use std::process::Command;
 
@@ -79,6 +80,33 @@ version = "0.1.0"
         .contains("Copyright 2018"));
 }
 
+#[test]
+fn it_substitutes_os_arch() {
+    let template = dir("template")
+        .file("some-file", r#"{{os-arch}}"#)
+        .init_git()
+        .build();
+
+    let dir = dir("main").build();
+
+    binary()
+        .arg("generate")
+        .arg("--git")
+        .arg(template.path())
+        .arg("--name")
+        .arg("foobar-project")
+        .arg("--branch")
+        .arg("main")
+        .current_dir(&dir.path())
+        .assert()
+        .success()
+        .stdout(predicates::str::contains("Done!").from_utf8());
+
+    assert!(dir
+        .read("foobar-project/some-file")
+        .contains(&format!("{}-{}", env::consts::OS, env::consts::ARCH).to_string()));
+}
+
 #[test]
 fn it_kebabcases_projectname_when_passed_to_flag() {
     let template = dir("template")