cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.76k stars 176 forks source link

bump clap2 to clap4-derive #306

Closed TD-Sky closed 1 year ago

TD-Sky commented 1 year ago

I only refactor the style of using clap, the semantic stay the same.

The only one broken change is, --fuzzy must have a value.

cantino commented 1 year ago

Thanks for working on this @TD-Sky!

TD-Sky commented 1 year ago

Sorry, I fixed the warning from clippy and retest it locally. It's OK now.

cantino commented 1 year ago

Hey @TD-Sky, the following patch should make this compatible with master:

diff --cc src/settings.rs
index 472c5b4,23c8163..0000000
--- a/src/settings.rs
+++ b/src/settings.rs
diff --git a/src/cli.rs b/src/cli.rs
index 48d9591..53bfc76 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -42,9 +42,9 @@ pub enum SubCommand {
         #[arg(value_name = "EXIT_CODE", short, long)]
         exit: Option<i32>,

-        /// Also append new history to $HISTFILE/$MCFLY_HISTFILE (e.q., .bash_history)
-        #[arg(long)]
-        append_to_histfile: bool,
+        /// Also append command to the given file (e.q., .bash_history)
+        #[arg(value_name = "HISTFILE", short, long)]
+        append_to_histfile: Option<String>,

         /// The time that the command was run (default now)
         #[arg(value_name = "UNIX_EPOCH", short, long)]
@@ -82,7 +82,7 @@ pub enum SubCommand {
         delete_without_confirm: bool,

         /// Write results to file, including selection mode, new commandline, and any shell-specific requests
-        #[arg(short, long)]
+        #[arg(value_name = "PATH", short, long)]
         output_selection: Option<String>,
     },
diff --git a/src/settings.rs b/src/settings.rs
index 472c5b4..110aee2 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -74,7 +74,7 @@ pub struct Settings {
     pub when_run: Option<i64>,
     pub exit_code: Option<i32>,
     pub old_dir: Option<String>,
-    pub append_to_histfile: bool,
+    pub append_to_histfile: Option<String>,
     pub refresh_training_cache: bool,
     pub lightmode: bool,
     pub key_scheme: KeyScheme,
@@ -102,7 +102,7 @@ impl Default for Settings {
             exit_code: None,
             old_dir: None,
             refresh_training_cache: false,
-            append_to_histfile: false,
+            append_to_histfile: None,
             debug: false,
             fuzzy: 0,
             lightmode: false,

However, your PR isn't working for me. When I run mcfly init bash, for example, it doesn't print out anything. Have you tried installing mcfly after making your changes?

TD-Sky commented 1 year ago

Hey @TD-Sky, the following patch should make this compatible with master:

diff --cc src/settings.rs
index 472c5b4,23c8163..0000000
--- a/src/settings.rs
+++ b/src/settings.rs
diff --git a/src/cli.rs b/src/cli.rs
index 48d9591..53bfc76 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -42,9 +42,9 @@ pub enum SubCommand {
         #[arg(value_name = "EXIT_CODE", short, long)]
         exit: Option<i32>,

-        /// Also append new history to $HISTFILE/$MCFLY_HISTFILE (e.q., .bash_history)
-        #[arg(long)]
-        append_to_histfile: bool,
+        /// Also append command to the given file (e.q., .bash_history)
+        #[arg(value_name = "HISTFILE", short, long)]
+        append_to_histfile: Option<String>,

         /// The time that the command was run (default now)
         #[arg(value_name = "UNIX_EPOCH", short, long)]
@@ -82,7 +82,7 @@ pub enum SubCommand {
         delete_without_confirm: bool,

         /// Write results to file, including selection mode, new commandline, and any shell-specific requests
-        #[arg(short, long)]
+        #[arg(value_name = "PATH", short, long)]
         output_selection: Option<String>,
     },
diff --git a/src/settings.rs b/src/settings.rs
index 472c5b4..110aee2 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -74,7 +74,7 @@ pub struct Settings {
     pub when_run: Option<i64>,
     pub exit_code: Option<i32>,
     pub old_dir: Option<String>,
-    pub append_to_histfile: bool,
+    pub append_to_histfile: Option<String>,
     pub refresh_training_cache: bool,
     pub lightmode: bool,
     pub key_scheme: KeyScheme,
@@ -102,7 +102,7 @@ impl Default for Settings {
             exit_code: None,
             old_dir: None,
             refresh_training_cache: false,
-            append_to_histfile: false,
+            append_to_histfile: None,
             debug: false,
             fuzzy: 0,
             lightmode: false,

However, your PR isn't working for me. When I run mcfly init bash, for example, it doesn't print out anything. Have you tried installing mcfly after making your changes?

I didn't realized my bad habit of not using the development version on my system in the past. I have did that and fixed the bug. There are nothing wrong happen.

cantino commented 1 year ago

Thanks @TD-Sky, much appreciated!