parent
b3b2527c5d
commit
2eacb8247b
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## 0.3.3 (unreleased)
|
||||
|
||||
- Fixed config flag in CLI
|
||||
|
||||
|
||||
## 0.3.2 (2018-03-05)
|
||||
|
||||
- Fix `serve` command trying to read all files as markdown
|
||||
|
|
|
@ -383,7 +383,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gutenberg"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
dependencies = [
|
||||
"chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
[package]
|
||||
name = "gutenberg"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
description = "A static site generator with everything built-in"
|
||||
description = "A fast static site generator with everything built-in"
|
||||
homepage = "https://github.com/Keats/gutenberg"
|
||||
repository = "https://github.com/Keats/gutenberg"
|
||||
keywords = ["static", "site", "generator", "blog"]
|
||||
|
|
|
@ -15,8 +15,8 @@ _gutenberg() {
|
|||
|
||||
local context curcontext="$curcontext" state line
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-c[Path to a config file other than config.toml]' \
|
||||
'--config[Path to a config file other than config.toml]' \
|
||||
'-c+[Path to a config file other than config.toml]' \
|
||||
'--config=[Path to a config file other than config.toml]' \
|
||||
'-h[Prints help information]' \
|
||||
'--help[Prints help information]' \
|
||||
'-V[Prints version information]' \
|
||||
|
|
|
@ -1,74 +1,79 @@
|
|||
|
||||
@('gutenberg', './gutenberg') | %{
|
||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||
using namespace System.Management.Automation
|
||||
using namespace System.Management.Automation.Language
|
||||
|
||||
Register-ArgumentCompleter -Native -CommandName 'gutenberg' -ScriptBlock {
|
||||
param($wordToComplete, $commandAst, $cursorPosition)
|
||||
|
||||
$command = '_gutenberg'
|
||||
$commandAst.CommandElements |
|
||||
Select-Object -Skip 1 |
|
||||
%{
|
||||
switch ($_.ToString()) {
|
||||
$commandElements = $commandAst.CommandElements
|
||||
$command = @(
|
||||
'gutenberg'
|
||||
for ($i = 1; $i -lt $commandElements.Count; $i++) {
|
||||
$element = $commandElements[$i]
|
||||
if ($element -isnot [StringConstantExpressionAst] -or
|
||||
$element.StringConstantType -ne [StringConstantType]::BareWord -or
|
||||
$element.Value.StartsWith('-')) {
|
||||
break
|
||||
}
|
||||
$element.Value
|
||||
}) -join ';'
|
||||
|
||||
$completions = @(switch ($command) {
|
||||
'gutenberg' {
|
||||
$command += '_gutenberg'
|
||||
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to a config file other than config.toml')
|
||||
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to a config file other than config.toml')
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
[CompletionResult]::new('init', 'init', [CompletionResultType]::ParameterValue, 'Create a new Gutenberg project')
|
||||
[CompletionResult]::new('build', 'build', [CompletionResultType]::ParameterValue, 'Builds the site')
|
||||
[CompletionResult]::new('serve', 'serve', [CompletionResultType]::ParameterValue, 'Serve the site. Rebuild and reload on change automatically')
|
||||
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Prints this message or the help of the given subcommand(s)')
|
||||
break
|
||||
}
|
||||
|
||||
'init' {
|
||||
$command += '_init'
|
||||
'gutenberg;init' {
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
break
|
||||
}
|
||||
|
||||
'build' {
|
||||
$command += '_build'
|
||||
'gutenberg;build' {
|
||||
[CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'Force the base URL to be that value (default to the one in config.toml)')
|
||||
[CompletionResult]::new('--base-url', 'base-url', [CompletionResultType]::ParameterName, 'Force the base URL to be that value (default to the one in config.toml)')
|
||||
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Outputs the generated site in the given path')
|
||||
[CompletionResult]::new('--output-dir', 'output-dir', [CompletionResultType]::ParameterName, 'Outputs the generated site in the given path')
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
break
|
||||
}
|
||||
|
||||
'serve' {
|
||||
$command += '_serve'
|
||||
'gutenberg;serve' {
|
||||
[CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'Interface to bind on')
|
||||
[CompletionResult]::new('--interface', 'interface', [CompletionResultType]::ParameterName, 'Interface to bind on')
|
||||
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Which port to use')
|
||||
[CompletionResult]::new('--port', 'port', [CompletionResultType]::ParameterName, 'Which port to use')
|
||||
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Outputs the generated site in the given path')
|
||||
[CompletionResult]::new('--output-dir', 'output-dir', [CompletionResultType]::ParameterName, 'Outputs the generated site in the given path')
|
||||
[CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'Changes the base_url')
|
||||
[CompletionResult]::new('--base-url', 'base-url', [CompletionResultType]::ParameterName, 'Changes the base_url')
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
break
|
||||
}
|
||||
|
||||
'help' {
|
||||
$command += '_help'
|
||||
'gutenberg;help' {
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
default {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$completions = @()
|
||||
|
||||
switch ($command) {
|
||||
|
||||
'_gutenberg' {
|
||||
$completions = @('init', 'build', 'serve', 'help', '-c', '-h', '-V', '--config', '--help', '--version')
|
||||
}
|
||||
|
||||
'_gutenberg_init' {
|
||||
$completions = @('-h', '-V', '--help', '--version')
|
||||
}
|
||||
|
||||
'_gutenberg_build' {
|
||||
$completions = @('-h', '-V', '-u', '-o', '--help', '--version', '--base-url', '--output-dir')
|
||||
}
|
||||
|
||||
'_gutenberg_serve' {
|
||||
$completions = @('-h', '-V', '-i', '-p', '-o', '-u', '--help', '--version', '--interface', '--port', '--output-dir', '--base-url')
|
||||
}
|
||||
|
||||
'_gutenberg_help' {
|
||||
$completions = @('-h', '-V', '--help', '--version')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$completions |
|
||||
?{ $_ -like "$wordToComplete*" } |
|
||||
Sort-Object |
|
||||
%{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
|
||||
}
|
||||
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
|
||||
Sort-Object -Property ListItemText
|
||||
}
|
||||
|
|
|
@ -32,13 +32,21 @@ _gutenberg() {
|
|||
|
||||
case "${cmd}" in
|
||||
gutenberg)
|
||||
opts=" -c -h -V --config --help --version init build serve help"
|
||||
opts=" -h -V -c --help --version --config init build serve help"
|
||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
case "${prev}" in
|
||||
|
||||
--config)
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-c)
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
|
@ -56,19 +64,19 @@ _gutenberg() {
|
|||
case "${prev}" in
|
||||
|
||||
--base-url)
|
||||
COMPREPLY=("<base_url>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-u)
|
||||
COMPREPLY=("<base_url>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--output-dir)
|
||||
COMPREPLY=("<output_dir>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-o)
|
||||
COMPREPLY=("<output_dir>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
|
@ -117,35 +125,35 @@ _gutenberg() {
|
|||
case "${prev}" in
|
||||
|
||||
--interface)
|
||||
COMPREPLY=("<interface>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-i)
|
||||
COMPREPLY=("<interface>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--port)
|
||||
COMPREPLY=("<port>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-p)
|
||||
COMPREPLY=("<port>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--output-dir)
|
||||
COMPREPLY=("<output_dir>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-o)
|
||||
COMPREPLY=("<output_dir>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--base-url)
|
||||
COMPREPLY=("<base_url>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-u)
|
||||
COMPREPLY=("<base_url>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -123,8 +123,10 @@ impl Config {
|
|||
/// Parses a config file from the given path
|
||||
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Config> {
|
||||
let mut content = String::new();
|
||||
let path = path.as_ref();
|
||||
let file_name = path.file_name().unwrap();
|
||||
File::open(path)
|
||||
.chain_err(|| "No `config.toml` file found. Are you in the right directory?")?
|
||||
.chain_err(|| format!("No `{:?}` file found. Are you in the right directory?", file_name))?
|
||||
.read_to_string(&mut content)?;
|
||||
|
||||
Config::parse(&content)
|
||||
|
|
|
@ -13,7 +13,7 @@ the command help by running `gutenberg <cmd> --help`.
|
|||
Creates the directory structure used by Gutenberg at the given directory.
|
||||
|
||||
```bash
|
||||
$ gutenberg init <my_site>
|
||||
$ gutenberg init my_site
|
||||
```
|
||||
|
||||
will create a new folder named `my_site` and the files/folders needed by
|
||||
|
@ -37,10 +37,17 @@ This is useful for example when you want to deploy previews of a site to a dynam
|
|||
deploy previews.
|
||||
|
||||
+You can override the default output directory 'public' by passing a other value to the `output-dir` flag.
|
||||
|
||||
```bash
|
||||
$ gutenberg build --output-dir $DOCUMENT_ROOT
|
||||
```
|
||||
|
||||
You can also point to another config file than `config.toml` like so - the position of the `config` option is important:
|
||||
|
||||
```bash
|
||||
$ gutenberg --config config.staging.toml build
|
||||
```
|
||||
|
||||
## serve
|
||||
|
||||
This will build and serve the site using a local server. You can also specify
|
||||
|
@ -63,3 +70,10 @@ hard refresh if possible.
|
|||
|
||||
Gutenberg does a best-effort to live reload but some changes cannot be handled automatically. If you
|
||||
fail to see your change, you will need to restart `gutenberg serve`.
|
||||
|
||||
|
||||
You can also point to another config file than `config.toml` like so - the position of the `config` option is important:
|
||||
|
||||
```bash
|
||||
$ gutenberg --config config.staging.toml serve
|
||||
```
|
||||
|
|
|
@ -10,6 +10,8 @@ pub fn build_cli() -> App<'static, 'static> {
|
|||
Arg::with_name("config")
|
||||
.short("c")
|
||||
.long("config")
|
||||
.default_value("config.toml")
|
||||
.takes_value(true)
|
||||
.help("Path to a config file other than config.toml")
|
||||
)
|
||||
.subcommands(vec![
|
||||
|
|
|
@ -29,7 +29,7 @@ mod prompt;
|
|||
fn main() {
|
||||
let matches = cli::build_cli().get_matches();
|
||||
|
||||
let config_file = matches.value_of("config").unwrap_or("config.toml");
|
||||
let config_file = matches.value_of("config").unwrap();
|
||||
|
||||
match matches.subcommand() {
|
||||
("init", Some(matches)) => {
|
||||
|
|
Loading…
Reference in New Issue