-
Notifications
You must be signed in to change notification settings - Fork 105
refactor: move commands into a module hierarchy #1336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| use crate::cli; | ||
| use anyhow::Result; | ||
| use clap::CommandFactory; | ||
| use clap_complete::{generate, Shell}; | ||
| use clap_complete::Shell; | ||
| use cli::CompletionShell; | ||
| use std::io; | ||
|
|
||
|
|
@@ -25,10 +25,8 @@ impl From<CompletionShell> for GeneratorType { | |
| } | ||
|
|
||
| /// Generic completion generator that supports both standard shells and nushell | ||
| pub fn generate_completion_for_command<T: CommandFactory>( | ||
| shell: CompletionShell, | ||
| app_name: &str, | ||
| ) -> Result<()> { | ||
| pub fn generate<T: CommandFactory>(shell: CompletionShell, app_name: &str) -> Result<()> { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| use clap_complete::generate; | ||
| let mut cmd = T::command(); | ||
| let mut stdout = io::stdout().lock(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| use anyhow::{anyhow, Result}; | ||
| use crate::config_file::{load_config_db, load_mut_config_db, save_config_db}; | ||
| use crate::utils::{print_juliaup_style, JuliaupMessageType}; | ||
| use anyhow::{bail, Context}; | ||
|
|
||
| pub fn run_command_config_autoinstall( | ||
| pub fn run( | ||
| value: Option<String>, | ||
| quiet: bool, | ||
| paths: &crate::global_paths::GlobalPaths, | ||
| ) -> Result<()> { | ||
| use crate::config_file::{load_config_db, load_mut_config_db, save_config_db}; | ||
| use crate::utils::{print_juliaup_style, JuliaupMessageType}; | ||
| use anyhow::Context; | ||
|
|
||
| ) -> anyhow::Result<()> { | ||
| match value { | ||
| Some(value_str) => { | ||
| let mut config_file = load_mut_config_db(paths) | ||
|
|
@@ -19,12 +17,10 @@ pub fn run_command_config_autoinstall( | |
| "true" => Some(true), | ||
| "false" => Some(false), | ||
| "default" => None, | ||
| _ => { | ||
| return Err(anyhow!( | ||
| _ => bail!( | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to |
||
| "Invalid value '{}'. Valid values are: true, false, default (to unset the property)", | ||
| value_str | ||
| )) | ||
| } | ||
| ), | ||
| }; | ||
|
|
||
| if new_value != config_file.data.settings.auto_install_channels { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| mod autoinstall; | ||
| pub use autoinstall::run as autoinstall; | ||
|
|
||
| #[cfg(feature = "selfupdate")] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved feature gates to module-level where possible |
||
| mod background_self_update; | ||
| #[cfg(feature = "selfupdate")] | ||
| pub use background_self_update::run as background_self_update; | ||
|
|
||
| #[cfg(feature = "selfupdate")] | ||
| mod modify_path; | ||
| #[cfg(feature = "selfupdate")] | ||
| pub use modify_path::run as modify_path; | ||
|
|
||
| #[cfg(feature = "selfupdate")] | ||
| mod startup_self_update; | ||
| #[cfg(feature = "selfupdate")] | ||
| pub use startup_self_update::run as startup_self_update; | ||
|
|
||
| #[cfg(not(windows))] | ||
| mod symlinks; | ||
| #[cfg(not(windows))] | ||
| pub use symlinks::run as symlinks; | ||
|
|
||
| mod versionsdb_update; | ||
| pub use versionsdb_update::run as versionsdb_update; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was testing the feature powerset with cargo-hack. Since the windows crate is only available on windows, it threw a compile error.