Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
# Command-line interface

This chapter covers how to use the application from the command line to convert
Markdown files to various output formats. Without specifying any command-line
arguments, the application will launch a graphical user interface.

## Common arguments

The most frequently used command-line arguments include:

* `-h` -- displays all command-line arguments, then exits.
* `-i` -- sets the input file name, must be a full path.
* `-o` -- sets the output file name, can be a relative path.
* `-s` -- sets a variable name and value at build time (dynamic data).

Setting a variable name on the command line useful, for example, to pass in a
product guide version number.

## Example usage

The following invocations will convert `01.md` into the respective file
formats, determined by the file name extension. In the first case, it will
become an XHTML page. In the second case, it will become a plain-text document
with all variables interpolated and replaced.

``` bash
keenwrite.bin \
  -i "${HOME}/document/01.md" \
  -o document.xhtml

keenwrite.bin \
  -i "${HOME}/document/01.md" \
  -o document.txt \
  -v "${HOME}/document/variables.yaml"
```

The following invocation will convert `01.Rmd` to a PDF file and replace
the metadata using values from the variable definitions file.

``` bash
keenwrite.bin \
  -i "${HOME}/document/01.Rmd" \
  -o document.pdf \
  --image-dir="${HOME}/document/images" \
  -v "${HOME}/document/variables.yaml" \
  --metadata="title={{book.title}}" \
  --metadata="author={{book.author}}" \
  --r-dir="${HOME}/document/R" \
  --r-script="${HOME}/document/R/bootstrap.R" \
  --theme-dir="{{install.config.unix}}/themes/boschet"
```

Directory or file names containing spaces must be quoted. For example, on
Windows:

``` bash
keenwrite.bin -i "C:\Users\My Documents\01.Rmd" -o document.pdf
```