-
Notifications
You must be signed in to change notification settings - Fork 940
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 --output-dir parameters to commands 'serve' and 'build' #191
Conversation
What are the reasons against using the default one? |
I'd like to create several themes that can work together with the same content. It would be convienient to render different variants by just changing the (Ideally, an additional '--config-file config_something.toml' parameter, would make this perfect.) |
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.
Few comments but looks good otherwise.
Can you change the PR to be on the next
branch though please?
src/cmd/build.rs
Outdated
@@ -5,8 +5,9 @@ use site::Site; | |||
|
|||
use console; | |||
|
|||
pub fn build(config_file: &str, base_url: Option<&str>) -> Result<()> { | |||
pub fn build(config_file: &str, base_url: Option<&str>, public: &str) -> Result<()> { |
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 would name public
output_dir
instead, public is not very explicit in the code
src/cmd/serve.rs
Outdated
@@ -77,7 +77,7 @@ fn rebuild_done_handling(broadcaster: &Sender, res: Result<()>, reload_path: &st | |||
} | |||
} | |||
|
|||
pub fn serve(interface: &str, port: &str, config_file: &str) -> Result<()> { | |||
pub fn serve(interface: &str, port: &str, public: &str, config_file: &str) -> Result<()> { |
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.
same as above
src/main.rs
Outdated
@@ -43,7 +43,8 @@ fn main() { | |||
("build", Some(matches)) => { | |||
console::info("Building site..."); | |||
let start = Instant::now(); | |||
match cmd::build(config_file, matches.value_of("base_url")) { | |||
let public = matches.value_of("output_dir").unwrap_or("public"); |
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.
Is the unwrap
needed since there is a default value in clap
?
src/main.rs
Outdated
@@ -54,8 +55,9 @@ fn main() { | |||
("serve", Some(matches)) => { | |||
let interface = matches.value_of("interface").unwrap_or("127.0.0.1"); | |||
let port = matches.value_of("port").unwrap_or("1111"); | |||
let public = matches.value_of("output_dir").unwrap_or("public"); |
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.
same as above
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 followed the same structure as :
interface
https://github.com/Keats/gutenberg/blob/master/src/cli.rs#L38
https://github.com/Keats/gutenberg/blob/master/src/main.rs#L55
port
https://github.com/Keats/gutenberg/blob/master/src/cli.rs#L43
https://github.com/Keats/gutenberg/blob/master/src/main.rs#L56
Please advice
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'm just not sure how the default works, I guess you can try removing the unwrap_or
and see if it still works?
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.
Without the unwrap_or
, the type goes from &str
to Option<&str>
.
It could be made working with if let Some(x) = ..{}
, but IMHO that would be less clearer then the unwrap_or
.
What might be interesting, to make the main.rs
more uniform, is make the same unwrap_or
for base_url
change:
- https://github.com/Keats/gutenberg/blob/master/src/main.rs#L46
- https://github.com/Keats/gutenberg/blob/master/src/cmd/build.rs#L10-L12
Please advice.
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.
the type goes from &str to Option<&str>
I guess with a default, it can never be None
right? So a normal .unwrap()
would work
$ gutenberg build --output-dir $DOCUMENT_ROOT | ||
``` | ||
|
||
This is useful for example when you want to generate a site to a different document-root. |
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.
This sentence seems a bit redundant, I would remove it
See getzola#191 for details.
Looks like tests are failing now. Can you also remove my commit from your branch? |
There's still my commit in the list. You can probably just merge all your commits and delete mine to fix it |
Sorry; my git knowledge is not sufficient. |
So that would look something like: $ git rebase -i HEAD~7 (7 here is a number representing all the commits in the branch, the one at the top should be mine) On my commit and the manual revert replace |
Add the detection of ChangeKind::Sass to tests Add --output-dir parameters to commands 'serve' and 'build' Update documentation and command line completion with 'output-dir' flag processed feedback See getzola#191 for details. Add trailing_slash opt. to get_url (getzola#173) * Added inital trailing_slash impl * Added simple test * Updated docs website to use trailing_slash option * Updated documentation to reflect new trailing_slash option * Added combined cachebust and trailing_slash test Add get_taxonomy_url global_fn And fix bug with taxonomies urls Add earliest Rust version to travis Fix tests and add taxonomies to changelog Update to Tera 0.11 beta Update Tera in cargo.lock Add default templates repeat paste fix
44305fe
to
fbecd9e
Compare
Ha I think the rebase merging got some earlier commits. Git 😨 |
I've added the changes in 14edd2b |
This is useful for example when you want to generate a site to a different document-root.