-
Notifications
You must be signed in to change notification settings - Fork 510
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
#340 Allow justfile without workdir #355
Changes from 3 commits
65e3a53
3c345b4
45512fd
5adf44c
72772ad
07fa147
6cb7eaa
119b798
7f41ec4
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,6 +1,6 @@ | ||
use common::*; | ||
|
||
use std::{convert, ffi}; | ||
use std::{convert, ffi }; | ||
use clap::{App, Arg, ArgGroup, AppSettings}; | ||
use configuration::DEFAULT_SHELL; | ||
use misc::maybe_s; | ||
|
@@ -86,8 +86,7 @@ pub fn run() { | |
.short("f") | ||
.long("justfile") | ||
.takes_value(true) | ||
.help("Use <JUSTFILE> as justfile. --working-directory must also be set") | ||
.requires("WORKING-DIRECTORY")) | ||
.help("Use <JUSTFILE> as justfile. --working-directory can be set [default: supplied justfile location]")) | ||
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. I think that since the behavior of just in setting the working directory is the same as normal when using this flag, we can make the comment shorter. Just 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. Done. |
||
.arg(Arg::with_name("LIST") | ||
.short("l") | ||
.long("list") | ||
|
@@ -187,7 +186,12 @@ pub fn run() { | |
.collect::<Vec<&str>>(); | ||
|
||
let justfile_option = matches.value_of("JUSTFILE"); | ||
let working_directory_option = matches.value_of("WORKING-DIRECTORY"); | ||
let mut working_directory_option = matches.value_of("WORKING-DIRECTORY"); | ||
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. Let's change 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. Done. |
||
|
||
if justfile_option.is_some() && working_directory_option.is_none() { | ||
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. Let's change this to an
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. Done. |
||
let justfile_path = Path::new(justfile_option.unwrap()).parent(); | ||
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. If 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. Added none check. But there seems to be a known issue(rust-lang/rust#36861) with parent returning "" in certain cases. Please suggest if it can be handled in a better way. 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. Thanks for the changes! Let's resolve the justfile to an absolute path, and then using the parent of that. 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. That should fix the issue with parent returning 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. Disclaimer: I am very new to Rust :-), and although I understand reference concept, not able to find a 'Rust way' to deal with following situation and so having trouble with the code:
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. No worries at all, we were all new to Rust once :) Can you push the code (even if it's broken) to the PR branch so I can try it out? 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. Done. It's broken. |
||
working_directory_option = justfile_path.unwrap().to_str(); | ||
} | ||
|
||
let text; | ||
if let (Some(file), Some(directory)) = (justfile_option, working_directory_option) { | ||
|
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.
It looks like this change isn't needed.
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.
Corrected extra space.