Compare commits
2 Commits
99722302a2
...
1974ed90be
| Author | SHA1 | Date | |
|---|---|---|---|
| 1974ed90be | |||
| 8039f5e778 |
18
src/app.rs
18
src/app.rs
@@ -95,9 +95,7 @@ impl App {
|
||||
}
|
||||
}
|
||||
Subcommand::Init => {
|
||||
let root = std::env::current_dir().expect("the current working directory");
|
||||
let path = root.file_name().expect("some file name");
|
||||
if let Err(e) = create_project(path.to_string_lossy().to_string()) {
|
||||
if let Err(e) = create_project(".") {
|
||||
eprintln!("Error initializing project: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
@@ -332,7 +330,19 @@ fn create_project<P: AsRef<Path>>(directory: P) -> std::io::Result<()> {
|
||||
std::fs::write("src/main.c", MAIN_C)?;
|
||||
std::fs::write(".gitignore", GITIGNORE)?;
|
||||
|
||||
let config = crate::config::Config::new(&pathdir.to_string_lossy());
|
||||
let lossy = pathdir.to_string_lossy();
|
||||
|
||||
let app_name = if lossy == "." {
|
||||
let root = std::env::current_dir()?;
|
||||
root.file_name()
|
||||
.expect("a valid file name")
|
||||
.to_string_lossy()
|
||||
.to_string()
|
||||
} else {
|
||||
lossy.to_string()
|
||||
};
|
||||
|
||||
let config = crate::config::Config::new(&app_name);
|
||||
|
||||
let serial = toml::to_string_pretty(&config).expect("a valid TOML structure");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user