-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #21. This PR implements the advise given by @sixfold-origami on Discord. It makes `bevy_cli` is proper library, moving all `clap` logic to `main.rs`. It also moves `main.rs` and `lint_driver.rs` to the `src/bin` folder, so they are distinct from library modules. I also added a few comments to `Cargo.toml` in 7d22ab7 in a drive-by pass. --------- Co-authored-by: Rose Peck <rosepeck1997@gmail.com>
- Loading branch information
1 parent
f23835f
commit 8b718fa
Showing
6 changed files
with
70 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//! The library backend for the Bevy CLI. | ||
pub mod lint; | ||
pub mod template; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use cargo_generate::{GenerateArgs, TemplatePath}; | ||
use std::path::PathBuf; | ||
|
||
/// Generates a new template to the returned [`PathBuf`] using the given name and Git repository. | ||
/// | ||
/// If `git` is [`None`], it will default to [TheBevyFlock/bevy_quickstart]. | ||
/// | ||
/// [TheBevyFlock/bevy_quickstart]: https://github.com/TheBevyFlock/bevy_quickstart | ||
pub fn generate_template(name: &str, git: Option<&str>) -> anyhow::Result<PathBuf> { | ||
cargo_generate::generate(GenerateArgs { | ||
template_path: template_path(git), | ||
name: Some(name.to_string()), | ||
// prevent conversion to kebab-case | ||
force: true, | ||
..Default::default() | ||
}) | ||
} | ||
|
||
/// Returns the [`TemplatePath`] for a given Git repository. | ||
/// | ||
/// If `git` is [`None`], it will default to `bevy_quickstart`. | ||
fn template_path(git: Option<&str>) -> TemplatePath { | ||
const DEFAULT_REPOSITORY: &str = "https://github.com/TheBevyFlock/bevy_quickstart.git"; | ||
const DEFAULT_BRANCH: &str = "cargo-generate"; | ||
|
||
if let Some(template) = git { | ||
TemplatePath { | ||
git: Some(template.to_string()), | ||
..Default::default() | ||
} | ||
} else { | ||
TemplatePath { | ||
git: Some(DEFAULT_REPOSITORY.to_string()), | ||
branch: Some(DEFAULT_BRANCH.to_string()), | ||
..Default::default() | ||
} | ||
} | ||
} |