Skip to content
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

Add command line switch to pueue add to specificy current working directory. #227

Closed
noyez opened this issue Aug 19, 2021 · 2 comments · Fixed by #234
Closed

Add command line switch to pueue add to specificy current working directory. #227

noyez opened this issue Aug 19, 2021 · 2 comments · Fixed by #234
Labels
t: Feature A new feature that needs implementation

Comments

@noyez
Copy link

noyez commented Aug 19, 2021

Is your feature request related to a problem? Please describe.
I often have many tmux windows open and i'm not always conscience which directory i'm in. Then i add a task to pueue and the output goes into the directory i happen to be. I'd like to be able to explicitly specify a current working directory for the command added so it can be consistent and explicit, rather than implicit from wherever the task was added to pueue.

Describe the solution you'd like
A command line option to pueue add such as -C to change the current working directory of the command that will be added to the queue.

Describe alternatives you've considered
simply try to execute pueue add in the same directory every time.

Additional context
This is a feature i could implement if you want to move forward.

@noyez noyez added the t: Feature A new feature that needs implementation label Aug 19, 2021
@noyez
Copy link
Author

noyez commented Aug 19, 2021

In fact i did implement it in about 20min. Only 6 lines difference.

diff --git a/client/cli.rs b/client/cli.rs
index 78db758..0e43e3e 100644
--- a/client/cli.rs
+++ b/client/cli.rs
@@ -54,6 +54,10 @@ pub enum SubCommand {
         /// This is useful when scripting and working with dependencies.
         #[clap(short, long)]
         print_task_id: bool,
+
+        /// Specify current working directory.
+        #[clap(name="cwd", short = 'C', long)]
+        cwd: Option<PathBuf>,
     },
     /// Remove tasks from the list.
     /// Running or paused tasks need to be killed first.
diff --git a/client/client.rs b/client/client.rs
index 04ca427..1077a1b 100644
--- a/client/client.rs
+++ b/client/client.rs
@@ -330,8 +330,9 @@ impl Client {
                 dependencies,
                 label,
                 print_task_id,
+                cwd,
             } => {
-                let cwd_pathbuf = current_dir()?;
+                let cwd_pathbuf = cwd.as_ref().map_or_else(||  current_dir(), |c| Ok(c.to_path_buf()))?;
                 let cwd = cwd_pathbuf
                     .to_str()
                     .context("Cannot parse current working directory (Invalid utf8?)")?;

@Nukesor
Copy link
Owner

Nukesor commented Aug 19, 2021

Sounds like a reasonable addition :)

I'll probably add it next week, as I'm quite busy for the next few days and I also need a little break from Pueue ;D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: Feature A new feature that needs implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants