Skip to content

Commit

Permalink
add --no-render-dir flag to disable writing config to disk.
Browse files Browse the repository at this point in the history
  • Loading branch information
qubitrenegade committed Feb 3, 2019
1 parent 015ba34 commit 5e6aaf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions components/hab/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ pub fn get() -> App<'static, 'static> {
(@arg MOCK_DATA: -m --("mock-data") +takes_value "Path to json file with mock data for template, defaults to none")
(@arg PRINT: -p --("print") "Prints config to STDOUT")
(@arg RENDER_DIR: -r --("render-dir") +takes_value "Path to render templates to, defaults to ./results/")
(@arg NO_WRITE_FILE: -n --("no-render") --("no-render-dir") "Don't write anything to disk, ignores --render-dir")
)
)
(@subcommand ring =>
Expand Down
8 changes: 6 additions & 2 deletions components/hab/src/command/plan/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn start(
user_toml_path: Option<String>,
mock_data_path: Option<String>,
print: bool,
no_render_dir: bool,
render_dir: String,
) -> Result<()> {
// Strip the file name out of our passed template
Expand Down Expand Up @@ -102,8 +103,11 @@ pub fn start(
ui.warn(format!("========### End rendered template: {}", &template_path))?;
}

// Render our template file
create_with_template(ui, &format!("{}/{}", render_dir, file_name), &rendered_template)?;
if !(no_render_dir) {
// Render our template file
create_with_template(ui, &format!("{}/{}", render_dir, file_name), &rendered_template)?;
}

ui.br()?;
// not really sure this is correct...
Ok(())
Expand Down
2 changes: 2 additions & 0 deletions components/hab/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ fn sub_plan_render(ui: &mut UI, m: &ArgMatches<'_>) -> Result<()> {
};

let print = m.is_present("PRINT");
let no_render_dir = m.is_present("NO_WRITE_FILE");

let render_dir = match m.value_of("RENDER_DIR") {
Some(name) => name.to_string(),
Expand All @@ -689,6 +690,7 @@ fn sub_plan_render(ui: &mut UI, m: &ArgMatches<'_>) -> Result<()> {
user_toml_path,
mock_data_path,
print,
no_render_dir,
render_dir,
)
}
Expand Down

0 comments on commit 5e6aaf7

Please sign in to comment.