Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default template support #21

Merged
merged 26 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bb36c38
feat(init): :sparkles: Add default templates
ostev Jul 10, 2021
e94c0be
Merge branch 'arctic-hen7:main' into main
ostev Jul 10, 2021
605699e
feat(init): :sparkles: Add edit template file flag
ostev Jul 11, 2021
54d7531
docs(help): :memo: Update help text to add `-e`
ostev Jul 11, 2021
a9a6100
fix(init): :bug: Change template environment variable
ostev Jul 11, 2021
1886ec8
docs(help): :memo: Update help with new env var
ostev Jul 11, 2021
c7e9c29
docs(wiki): :memo: Update docs with new env var
ostev Jul 11, 2021
78b9a24
Update src/help.rs
ostev Jul 12, 2021
62d00a5
Update src/help.rs
ostev Jul 12, 2021
ccaf18d
Update src/init.rs
ostev Jul 12, 2021
91e2aef
Update src/init.rs
ostev Jul 12, 2021
dd20fda
Update src/bin/main.rs
ostev Jul 12, 2021
17d799c
Update src/bin/main.rs
ostev Jul 12, 2021
46a75db
refactor(init): :recycle: use `String`s as errors
ostev Jul 12, 2021
53ce4af
Merge branch 'main' of github.com:ostev/bonnie into main
ostev Jul 12, 2021
40e0f71
refactor: :recycle: Extract `-e` into function
ostev Jul 12, 2021
35fc4c9
refactor(init): :recycle: Remove "Initialising..." text
ostev Jul 12, 2021
92932c9
refactor(init): :recycle: Remove needles format\
ostev Jul 12, 2021
a83bb46
refactor(init): :recycle: Remove unclear names
ostev Jul 12, 2021
ece01cc
fix: :bug: Add error message if template not found
ostev Jul 12, 2021
1f79bdb
docs(wiki): :memo: Add info about `-e`
ostev Jul 12, 2021
cc193aa
fix: :bug: Add more descriptive error
ostev Jul 12, 2021
a7e9625
fix(init): :bug: Add actual path to error message
ostev Jul 12, 2021
829b4a4
Update src/template.rs
ostev Jul 12, 2021
934611a
Update src/template.rs
ostev Jul 12, 2021
600227e
style: :art: Run `cargo fmt`
ostev Jul 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn core() -> Result<i32, String> {
},
)?;

println!("A new Bonnie configuration file has been initialized at [PATH]!");
println!("A new Bonnie configuration file has been initialized at ./bonnie.toml!");
arctic-hen7 marked this conversation as resolved.
Show resolved Hide resolved

return Ok(0);
} else if prog_args[0] == "-h" || prog_args[0] == "--help" {
Expand Down
12 changes: 9 additions & 3 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ pub fn edit() -> Result<(), String> {

let child;

let command;

if cfg!(target_os = "windows") {
// We need to spawn a `powershell` process to make `start` available.
child = OsCommand::new("powershell")
.arg(format!("start '{}'", template_path))
.spawn()
.map(|mut x| x.wait());

command = format!("powershell -command 'start {}'", template_path);
} else {
let editor = PathBuf::from(env::var("EDITOR").unwrap_or("nano".to_string()));

Expand All @@ -70,16 +74,18 @@ pub fn edit() -> Result<(), String> {
)?;

child = OsCommand::new(safe_editor)
.arg(template_path)
.arg(&template_path)
.spawn()
.map(|mut x| x.wait());

command = format!("{} {}", safe_editor, template_path);
}

let result = match child {
Ok(_) => Ok(()),
Err(err) => Err(format!(
"Your editor failed to start with the following error: {:#?}",
err
"Your editor failed to start with the following error: {}. I ran the command {}",
arctic-hen7 marked this conversation as resolved.
Show resolved Hide resolved
err, command
)),
};

Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 0c133e to 5cdd38