Skip to content

Commit

Permalink
Merge branch 'master' into init
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Nov 22, 2023
2 parents 680bb19 + f1ae3ed commit 2a167fb
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ The goal is to create an opinionated tool to support a reliably inviting onboard
## Installation

```
pip install huak
pip install huak
```

To install Huak from source use `Cargo`:
To install Huak from source using Cargo:

```
cargo install --git https://github.com/cnpryer/huak.git huak
Expand Down
2 changes: 2 additions & 0 deletions crates/huak-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ fn fmt(config: &Config, options: &FormatOptions) -> HuakResult<()> {
ops::format_project(config, options)
}

#[allow(clippy::too_many_arguments)]
#[allow(clippy::fn_params_excessive_bools)]
fn init(
app: bool,
_lib: bool,
Expand Down
8 changes: 4 additions & 4 deletions crates/huak-cli/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ mod tests {
assert_cmd_snapshot!(Command::new("huak").arg("init").arg("--help"));
}

#[test]
fn test_install_help() {
assert_cmd_snapshot!(Command::new("huak").arg("install").arg("--help"));
}
// #[test]
// fn test_install_help() {
// assert_cmd_snapshot!(Command::new("huak").arg("install").arg("--help"));
// }

#[test]
fn test_lint_help() {
Expand Down
3 changes: 1 addition & 2 deletions crates/huak-cli/tests/snapshots/r#mod__tests__help-2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Commands:
completion Generates a shell completion script for supported shells
fix Auto-fix fixable lint conflicts
fmt Format the project's Python code
init Initialize the existing project
install Install the dependencies of an existing project
init Initialize the current project
lint Lint the project's Python code
new Create a new project at <path>
publish Builds and uploads current project to a registry
Expand Down
3 changes: 1 addition & 2 deletions crates/huak-cli/tests/snapshots/r#mod__tests__help.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Commands:
completion Generates a shell completion script for supported shells
fix Auto-fix fixable lint conflicts
fmt Format the project's Python code
init Initialize the existing project
install Install the dependencies of an existing project
init Initialize the current project
lint Lint the project's Python code
new Create a new project at <path>
publish Builds and uploads current project to a registry
Expand Down
13 changes: 10 additions & 3 deletions crates/huak-cli/tests/snapshots/r#mod__tests__init_help.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: crates/huak_cli/tests/mod.rs
source: crates/huak-cli/tests/mod.rs
info:
program: huak
args:
Expand All @@ -9,14 +9,21 @@ info:
success: true
exit_code: 0
----- stdout -----
Initialize the existing project
Initialize the current project

Usage: huak init [OPTIONS]
Usage: huak init [OPTIONS] [MANIFEST] [NO_ENV] [OPTIONAL_DEPENDENCIES]... [-- <TRAILING>...]

Arguments:
[MANIFEST] Initialize with a project manifest
[NO_ENV] Initialize without setting up a Python environment
[OPTIONAL_DEPENDENCIES]... Optional dependency groups to install
[TRAILING]... Pass trailing arguments with `--`

Options:
--app Use an application template
--lib Use a library template [default]
--no-vcs Don't initialize VCS in the project
-f, --force Force the initialization
-q, --quiet
--no-color
-h, --help Print help
Expand Down
26 changes: 0 additions & 26 deletions crates/huak-cli/tests/snapshots/r#mod__tests__install_help.snap

This file was deleted.

6 changes: 3 additions & 3 deletions crates/huak-package-manager/src/ops/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ pub fn init_python_env(

// TODO(cnpryer): Can't remember if clap parses "." as curr dir
let mut manifest_path = manifest.unwrap_or(ws.root().join("pyproject.toml"));

if manifest_path
.file_name()
.is_some_and(|it| !it.eq_ignore_ascii_case("pyproject.toml"))
{
return Err(Error::ManifestFileNotSupported(manifest_path));
} else {
manifest_path.set_file_name("pyproject.toml");
}

manifest_path.set_file_name("pyproject.toml");

let Ok(manifest) = LocalManifest::new(manifest_path) else {
return config
.terminal()
Expand Down Expand Up @@ -131,6 +130,7 @@ pub fn init_python_env(
return Ok(());
}

// TODO(cnpryer): Relax this by attempting to use existing environments
if force {
// Remove the current Python virtual environment if one exists.
match ws.current_python_environment() {
Expand Down

0 comments on commit 2a167fb

Please sign in to comment.