Skip to content

Commit 493d604

Browse files
author
Alexander Weber
committed
code formatting
1 parent bd83a6a commit 493d604

File tree

7 files changed

+28
-23
lines changed

7 files changed

+28
-23
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
authors = ["Alexander Weber <[email protected]>"]
55
edition = "2018"
66
license = "MIT"
7-
description = "Standardizing messages the right way."
7+
description = "A powerful text templating tool."
88
homepage = "https://replicadse.github.io/complate"
99
repository = "https://github.com/replicadse/complate"
1010
keywords = ["cli", "template", "replace", "standardizing"]

examples/helm/render.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ echo ""
66
complate -e render -t chart -v "version=0.1.0"
77
echo ">>> values dev <<<"
88
echo ""
9-
MY_SECRET_PASS="pass:superpass" complate -e render -t dev --helpers --shell-trust=ultimate
9+
MY_SECRET_PASS="pass:superpass" complate -e render -t dev --trust
1010
echo ""
1111
echo ">>> values prod <<<"
1212
echo ""
13-
MY_SECRET_PASS="pass:superpass" complate -e render -t prod --helpers --shell-trust=ultimate
13+
MY_SECRET_PASS="pass:superpass" complate -e render -t prod --trust

src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum Command {
4545
pub struct RenderArguments {
4646
pub configuration: String,
4747
pub template: Option<String>,
48-
pub value_overrides: std::collections::HashMap<String, String>,
48+
pub value_overrides: HashMap<String, String>,
4949
pub shell_trust: ShellTrust,
5050
pub loose: bool,
5151
pub backend: Backend,
@@ -147,7 +147,7 @@ impl ClapArgumentLoader {
147147
.help("Overrides a certain value definition with a string.")))
148148
}
149149

150-
pub async fn load_from_cli() -> std::result::Result<CallArgs, Box<dyn std::error::Error>> {
150+
pub async fn load() -> Result<CallArgs, Box<dyn std::error::Error>> {
151151
let root_command = Self::root_command();
152152
let command_matches = root_command.get_matches();
153153

src/config.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
use std::collections::BTreeMap;
2+
13
#[derive(Debug, serde::Serialize, serde::Deserialize)]
24
pub struct Config {
35
pub version: String,
46
#[serde(default)]
5-
pub templates: std::collections::BTreeMap<String, Template>,
7+
pub templates: BTreeMap<String, Template>,
68
}
79

810
#[derive(Debug, serde::Serialize, serde::Deserialize)]
911
#[serde(rename_all = "snake_case", deny_unknown_fields)]
1012
pub struct Template {
1113
pub content: Content,
1214
#[serde(default)]
13-
pub values: std::collections::BTreeMap<String, VariableDefinition>,
15+
pub values: BTreeMap<String, VariableDefinition>,
1416
#[serde(default)]
15-
pub helpers: std::collections::BTreeMap<String, Helper>,
17+
pub helpers: BTreeMap<String, Helper>,
1618
}
1719

1820
#[derive(Debug, serde::Serialize, serde::Deserialize)]
@@ -51,12 +53,12 @@ pub enum VariableDefinition {
5153
Shell(String),
5254
Select {
5355
text: String,
54-
options: std::collections::BTreeMap<String, Option>,
56+
options: BTreeMap<String, Option>,
5557
},
5658
Check {
5759
text: String,
5860
separator: String,
59-
options: std::collections::BTreeMap<String, Option>,
61+
options: BTreeMap<String, Option>,
6062
},
6163
}
6264

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ pub mod render;
1212

1313
#[tokio::main]
1414
async fn main() -> Result<(), Box<dyn std::error::Error>> {
15-
let cmd = crate::args::ClapArgumentLoader::load_from_cli().await?;
15+
let cmd = args::ClapArgumentLoader::load().await?;
1616
cmd.validate().await?;
1717

1818
match cmd.command {
19-
| crate::args::Command::Manual { path, format } => {
19+
| args::Command::Manual { path, format } => {
2020
let out_path = PathBuf::from(path);
2121
std::fs::create_dir_all(&out_path)?;
2222
match format {
@@ -29,19 +29,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2929
}
3030
Ok(())
3131
},
32-
| crate::args::Command::Autocomplete { path, shell } => {
32+
| args::Command::Autocomplete { path, shell } => {
3333
let out_path = PathBuf::from(path);
3434
std::fs::create_dir_all(&out_path)?;
3535
reference::build_shell_completion(&out_path, &shell)?;
3636
Ok(())
3737
},
38-
| crate::args::Command::Init => {
38+
| args::Command::Init => {
3939
std::fs::create_dir_all("./.complate")?;
40-
std::fs::write("./.complate/config.yaml", crate::config::default_config().await)?;
40+
std::fs::write("./.complate/config.yaml", config::default_config().await)?;
4141
Ok(())
4242
},
43-
| crate::args::Command::Render(x) => {
44-
let res = crate::render::select_and_render(x).await?;
43+
| args::Command::Render(x) => {
44+
let res = render::select_and_render(x).await?;
4545
std::io::stdout().write_all(res.as_bytes())?;
4646
Ok(())
4747
},

src/render/cli.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use crate::error::Error;
22

33
use super::UserInput;
44
use async_trait::async_trait;
5-
use std::{collections::HashMap, result::Result};
5+
use std::{
6+
collections::{BTreeMap, HashMap},
7+
result::Result,
8+
};
69

710
pub struct CLIBackend<'a> {
811
shell_trust: &'a super::ShellTrust,
@@ -26,7 +29,7 @@ impl<'a> UserInput for CLIBackend<'a> {
2629
async fn select(
2730
&self,
2831
prompt: &str,
29-
options: &std::collections::BTreeMap<String, super::Option>,
32+
options: &BTreeMap<String, super::Option>,
3033
) -> Result<String, Box<dyn std::error::Error>> {
3134
let keys = options.keys().cloned().collect::<Vec<String>>();
3235
let display_vals = options.values().map(|x| x.display.to_owned()).collect::<Vec<String>>();
@@ -47,7 +50,7 @@ impl<'a> UserInput for CLIBackend<'a> {
4750
&self,
4851
prompt: &str,
4952
separator: &str,
50-
options: &std::collections::BTreeMap<String, super::Option>,
53+
options: &BTreeMap<String, super::Option>,
5154
) -> Result<String, Box<dyn std::error::Error>> {
5255
let keys = options.keys().cloned().collect::<Vec<String>>();
5356
let display_vals = options.values().map(|x| x.display.to_owned()).collect::<Vec<String>>();

src/render/ui.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::UserInput;
44
use async_trait::async_trait;
55
use cursive::traits::*;
66
use cursive::views::Dialog;
7-
use std::collections::{HashMap, HashSet};
7+
use std::collections::{BTreeMap, HashMap, HashSet};
88
use std::ops::Deref;
99
use std::result::Result;
1010

@@ -45,7 +45,7 @@ impl<'a> UserInput for UIBackend<'a> {
4545
async fn select(
4646
&self,
4747
prompt: &str,
48-
options: &std::collections::BTreeMap<String, super::Option>,
48+
options: &BTreeMap<String, super::Option>,
4949
) -> Result<String, Box<dyn std::error::Error>> {
5050
let keys = options.keys().cloned().collect::<Vec<String>>();
5151
let mut index_display = 0usize;
@@ -94,7 +94,7 @@ impl<'a> UserInput for UIBackend<'a> {
9494
&self,
9595
_: &str,
9696
separator: &str,
97-
options: &std::collections::BTreeMap<String, super::Option>,
97+
options: &BTreeMap<String, super::Option>,
9898
) -> Result<String, Box<dyn std::error::Error>> {
9999
let mut opts = Vec::new();
100100
{

0 commit comments

Comments
 (0)