Skip to content

Commit

Permalink
Clean up function signatures in cli.rs (#880)
Browse files Browse the repository at this point in the history
* sorted the params of the functions in cli.rs

* Update parameter ordering

* Clippy lint

---------

Co-authored-by: Chris Pryer <cnpryer@gmail.com>
  • Loading branch information
AtomsForPeace and cnpryer authored Dec 11, 2023
1 parent 462fdcc commit 4cb2100
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
60 changes: 30 additions & 30 deletions crates/huak-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {
let options = AddOptions {
install_options: InstallOptions { values: trailing },
};
add(&dependencies, group.as_ref(), config, &options)
add(&dependencies, group.as_ref(), &options, config)
}
Commands::Build { trailing } => {
let options = BuildOptions {
values: trailing,
install_options: InstallOptions { values: None },
};
build(config, &options)
build(&options, config)
}
Commands::Clean {
include_pyc,
Expand All @@ -338,7 +338,7 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {
include_pycache,
include_compiled_bytecode: include_pyc,
};
clean(config, &options)
clean(&options, config)
}
Commands::Completion { shell } => {
let options = CompletionOptions { shell };
Expand All @@ -351,7 +351,7 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {
include_types: false,
install_options: InstallOptions { values: None },
};
fix(config, &options)
fix(&options, config)
}
Commands::Fmt { check, trailing } => {
let mut args = if check {
Expand All @@ -366,7 +366,7 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {
values: Some(args),
install_options: InstallOptions { values: None },
};
fmt(config, &options)
fmt(&options, config)
}
Commands::Init {
app,
Expand All @@ -388,15 +388,15 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {

// TODO(cnpryer): Use `WorkspaceOptions` where possible.
init(
app,
lib,
manifest,
no_env,
optional_dependencies,
app,
force,
config,
&workspace_options,
lib,
no_env,
&install_options,
&workspace_options,
config,
)
}
Commands::Install {
Expand Down Expand Up @@ -435,14 +435,14 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {
uses_git: !no_vcs,
values: None,
};
new(app, lib, config, &options)
new(&options, app, lib, config)
}
Commands::Publish { trailing } => {
let options = PublishOptions {
values: trailing,
install_options: InstallOptions { values: None },
};
publish(config, &options)
publish(&options, config)
}
Commands::Python { command } => python(command, config),
Commands::Remove {
Expand All @@ -452,15 +452,15 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {
let options = RemoveOptions {
install_options: InstallOptions { values: trailing },
};
remove(&dependencies, config, &options)
remove(&dependencies, &options, config)
}
Commands::Run { command } => run(&command, config),
Commands::Test { trailing } => {
let options = TestOptions {
values: trailing,
install_options: InstallOptions { values: None },
};
test(config, &options)
test(&options, config)
}
Commands::Toolchain { command } => toolchain(command, config),
Commands::Update {
Expand All @@ -470,7 +470,7 @@ fn exec_command(cmd: Commands, config: &mut Config) -> HuakResult<()> {
let options = UpdateOptions {
install_options: InstallOptions { values: trailing },
};
update(dependencies, config, &options)
update(dependencies, &options, config)
}
Commands::Version => version(config),
}
Expand Down Expand Up @@ -510,8 +510,8 @@ fn activate(config: &Config) -> HuakResult<()> {
fn add(
dependencies: &[Dependency],
group: Option<&String>,
config: &Config,
options: &AddOptions,
config: &Config,
) -> HuakResult<()> {
let deps = dependencies
.iter()
Expand All @@ -523,34 +523,34 @@ fn add(
}
}

fn build(config: &Config, options: &BuildOptions) -> HuakResult<()> {
fn build(options: &BuildOptions, config: &Config) -> HuakResult<()> {
ops::build_project(config, options)
}

fn clean(config: &Config, options: &CleanOptions) -> HuakResult<()> {
fn clean(options: &CleanOptions, config: &Config) -> HuakResult<()> {
ops::clean_project(config, options)
}

fn fix(config: &Config, options: &LintOptions) -> HuakResult<()> {
fn fix(options: &LintOptions, config: &Config) -> HuakResult<()> {
ops::lint_project(config, options)
}

fn fmt(config: &Config, options: &FormatOptions) -> HuakResult<()> {
fn fmt(options: &FormatOptions, config: &Config) -> HuakResult<()> {
ops::format_project(config, options)
}

#[allow(clippy::too_many_arguments)]
#[allow(clippy::fn_params_excessive_bools)]
fn init(
app: bool,
_lib: bool,
manifest: Option<PathBuf>,
no_env: bool,
optional_dependencies: Option<Vec<String>>,
app: bool,
force: bool,
config: &Config,
workspace_options: &WorkspaceOptions,
no_env: bool,
_lib: bool,
install_options: &InstallOptions,
workspace_options: &WorkspaceOptions,
config: &Config,
) -> HuakResult<()> {
let res = if app {
ops::init_app_project(config, workspace_options)
Expand Down Expand Up @@ -592,15 +592,15 @@ fn lint(config: &Config, options: &LintOptions) -> HuakResult<()> {
ops::lint_project(config, options)
}

fn new(app: bool, _lib: bool, config: &Config, options: &WorkspaceOptions) -> HuakResult<()> {
fn new(options: &WorkspaceOptions, app: bool, _lib: bool, config: &Config) -> HuakResult<()> {
if app {
ops::new_app_project(config, options)
} else {
ops::new_lib_project(config, options)
}
}

fn publish(config: &Config, options: &PublishOptions) -> HuakResult<()> {
fn publish(options: &PublishOptions, config: &Config) -> HuakResult<()> {
ops::publish_project(config, options)
}

Expand All @@ -612,15 +612,15 @@ fn python(command: Python, config: &Config) -> HuakResult<()> {
}
}

fn remove(dependencies: &[String], config: &Config, options: &RemoveOptions) -> HuakResult<()> {
fn remove(dependencies: &[String], options: &RemoveOptions, config: &Config) -> HuakResult<()> {
ops::remove_project_dependencies(dependencies, config, options)
}

fn run(command: &[String], config: &Config) -> HuakResult<()> {
ops::run_command_str(&command.join(" "), config)
}

fn test(config: &Config, options: &TestOptions) -> HuakResult<()> {
fn test(options: &TestOptions, config: &Config) -> HuakResult<()> {
ops::test_project(config, options)
}

Expand All @@ -646,8 +646,8 @@ fn toolchain(command: Toolchain, config: &Config) -> HuakResult<()> {

fn update(
dependencies: Option<Vec<String>>,
config: &Config,
options: &UpdateOptions,
config: &Config,
) -> HuakResult<()> {
ops::update_project_dependencies(dependencies, config, options)
}
Expand Down
5 changes: 4 additions & 1 deletion crates/huak-package-manager/src/python_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ impl VenvConfig {
let file =
File::open(&path).unwrap_or_else(|_| panic!("failed to open {}", path.display()));
let buff_reader = BufReader::new(file);
let lines = buff_reader.lines().flatten().collect::<Vec<String>>();
let lines = buff_reader
.lines()
.map_while(Result::ok)
.collect::<Vec<String>>();

// Search for version = "X.X.X"
let mut version = Version::from_str("0.0.0")?;
Expand Down

0 comments on commit 4cb2100

Please sign in to comment.