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 7ae978b
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 89 deletions.
9 changes: 3 additions & 6 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 All @@ -46,8 +46,6 @@ cargo install --git https://github.com/cnpryer/huak.git huak
## Usage

```console
huak help

A Python package manager written in Rust and inspired by Cargo.

Usage: huak [OPTIONS] <COMMAND>
Expand All @@ -60,8 +58,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
7 changes: 6 additions & 1 deletion crates/huak-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ enum Commands {
#[arg(long)]
no_vcs: bool,
/// Initialize with a project manifest.
#[arg(long)]
manifest: Option<PathBuf>,
// TODO(cnpryer): https://github.com/cnpryer/huak/issues/853
// /// Initialize with requirements files.
Expand All @@ -100,8 +101,10 @@ enum Commands {
// /// Initialize with development requirements files.
// dev_requirements: Option<Vec<PathBuf>>,
/// Initialize without setting up a Python environment.
#[arg(long)]
no_env: bool,
/// Optional dependency groups to install.
#[arg(long)]
optional_dependencies: Option<Vec<String>>,
/// Force the initialization.
#[arg(short, long)]
Expand Down Expand Up @@ -512,6 +515,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 All @@ -530,7 +535,7 @@ fn init(
};

// If initialization failed because a manifest file already exists and the project
// initialization option 'with-env' is 'true' then we attempt to inititialize the
// initialization option 'no-env' is 'false' then we attempt to inititialize the
// project's Python environment.
if res
.as_ref()
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
35 changes: 26 additions & 9 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,17 +9,34 @@ info:
success: true
exit_code: 0
----- stdout -----
Initialize the existing project
Initialize the current project

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

Arguments:
[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
-q, --quiet
--no-color
-h, --help Print help
--app
Use an application template
--lib
Use a library template [default]
--no-vcs
Don't initialize VCS in the project
--manifest <MANIFEST>
Initialize with a project manifest
--no-env
Initialize without setting up a Python environment
--optional-dependencies <OPTIONAL_DEPENDENCIES>
Optional dependency groups to install
-f, --force
Force the initialization
-q, --quiet

--no-color

-h, --help
Print help

----- stderr -----

26 changes: 0 additions & 26 deletions crates/huak-cli/tests/snapshots/r#mod__tests__install_help.snap

This file was deleted.

37 changes: 1 addition & 36 deletions crates/huak-package-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,7 @@
//! 2. Making some change to the project
//! 3. Running tests
//! 4. Distributing the project
//!
//!```zsh
//! ❯ huak help
//!
//! A Python package manager written in Rust and inspired by Cargo.
//!
//! Usage: huak [OPTIONS] <COMMAND>
//!
//! Commands:
//! activate Activate the virtual environment
//! add Add dependencies to the project
//! build Build tarball and wheel for the project
//! clean Remove tarball and wheel from the built project
//! 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
//! lint Lint the project's Python code
//! new Create a new project at <path>
//! publish Builds and uploads current project to a registry
//! python Manage Python installations
//! remove Remove dependencies from the project
//! run Run a command with Huak
//! test Test the project's Python code
//! toolchain Manage toolchains
//! update Update the project's dependencies
//! version Display the version of the project
//! help Print this message or the help of the given subcommand(s)
//!
//! Options:
//! -q, --quiet
//! --no-color
//! -h, --help Print help
//! -V, --version Print version
//!```

mod config;
mod dependency;
mod environment;
Expand Down
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 7ae978b

Please sign in to comment.