1
0
mirror of https://github.com/lise-henry/crowbook synced 2024-09-27 01:30:44 +02:00
crowbook/guide/arguments.md

277 lines
7.0 KiB
Markdown
Raw Normal View History

2016-02-21 20:33:30 +01:00
Arguments
=========
2016-10-21 19:36:50 +02:00
Crowbook can take a number of arguments:
2016-02-21 20:33:30 +01:00
```text
2016-10-18 00:49:17 +02:00
Render a Markdown book in EPUB, PDF or HTML.
2016-02-21 20:33:30 +01:00
USAGE:
2016-10-18 00:49:17 +02:00
crowbook [OPTIONS] [--] [BOOK]
2016-03-01 18:46:59 +01:00
FLAGS:
2016-10-18 00:49:17 +02:00
-h, --help Print help information
-l, --list-options List all possible options
-p, --proofread Enable proofreading
-q, --quiet Don't print info/error messages
2016-03-01 21:41:23 +01:00
-s, --single Use a single Markdown file instead of a book configuration file
-v, --verbose Print warnings in parsing/rendering
2016-10-18 00:49:17 +02:00
-V, --version Print version information
2016-02-21 20:33:30 +01:00
OPTIONS:
2016-10-18 00:49:17 +02:00
-c, --create <FILES>... Create a new book with existing Markdown files
-o, --output <FILE> Specify output file
--print-template <TEMPLATE> Prints the default content of a template
--set <KEY_VALUES> Set a list of book options
-t, --to <FORMAT> Generate specific format
2016-02-21 20:33:30 +01:00
ARGS:
2016-10-18 00:49:17 +02:00
<BOOK> File containing the book configuration file, or a Markdown file when called with --single
```
2016-02-21 20:33:30 +01:00
2016-10-21 19:36:50 +02:00
The most important option is obviously <BOOK>, i.e. the book
2016-11-19 00:34:05 +01:00
configuration file. It is mandatory in most cases: if you don't
2016-10-21 19:36:50 +02:00
pass it, Crowbook will simply display this help message. In a normal use case this is
the only argument you'll need to pass, and Crowbook will generate
2016-02-21 20:33:30 +01:00
the book in all formats specified in the configuration file.
2016-10-21 19:36:50 +02:00
It is, however, possible to pass more arguments to `crowbook`:
2016-02-21 20:33:30 +01:00
`--create`
---------
**Usage**: `crowbook [BOOK] --create file_1.md file_2.md ...`
2016-02-21 20:33:30 +01:00
Creates a new book from a list of Markdown files. It will generate a
2016-03-01 21:41:23 +01:00
book configuration file with all file names specified as
chapters. It either prints the result to stdout (if `BOOK` is not
specified) or generate the file `BOOK` (or abort if it already
exists).
2016-02-21 20:33:30 +01:00
2016-02-22 04:51:27 +01:00
### Examples ###
2016-02-21 20:33:30 +01:00
```bash
crowbook foo.book --create README.md ChangeLog.md LICENSE.md
2016-02-21 20:33:30 +01:00
```
will generate a file `foo.book` containing:
```yaml
2016-02-21 20:33:30 +01:00
author: Your name
title: Your title
lang: en
# Uncomment and fill to generate files
# output.html: some_file.html
# output.epub: some_file.epub
# output.pdf: some_file.pdf
# Uncomment and fill to set cover image (for Epub)
# cover: some_cover.png
# List of chapters
+ README.md
+ ChangeLog.md
+ LICENSE.md
```
while
```bash
crowbook --create README.md ChangeLog.md LICENSE.md
```
will print the same result, but to stdout (without creating a file).
2016-12-31 00:00:31 +01:00
When `crowbook` is run with `--create`, it can also use the
2016-02-22 04:51:27 +01:00
keys/values set by `--set` (see below):
```bash
2016-03-01 18:46:59 +01:00
$ crowbook foo.book --create file1.md file2.md --set author "Pierre Dupont" title "Mon Å“uvre" lang fr
2016-02-22 04:51:27 +01:00
```
2016-11-19 00:34:05 +01:00
will generate a `foo.book` file containing:
2016-02-22 04:51:27 +01:00
```yaml
2016-02-22 04:51:27 +01:00
author: Pierre Dupont
2016-02-25 19:26:49 +01:00
title: Mon Å“uvre
2016-02-22 04:51:27 +01:00
lang: fr
# List of chapters
+ file1.md
+ file2.md
```
2016-03-01 18:46:59 +01:00
`--single`
----------
**usage**: `crowbook --single <FILE>`
(or `crowbook -s <FILE>`)
This argument allows to give `crowbook` a single Markdown file. This
2016-03-01 18:46:59 +01:00
file can contain an inline YAML block to set some book options. Inline
2016-12-31 00:00:31 +01:00
YAML blocks must start and end with a line containing only `---` (three dashes). E.g:
2016-03-01 18:46:59 +01:00
```yaml
2016-03-01 18:46:59 +01:00
---
author: Joan Doe
title: A short story
output.html: short.html
2016-03-01 18:46:59 +01:00
---
```
If this YAML block is not at the beginning of a file, it must also be
preceded by a blank line.
2016-03-01 21:41:23 +01:00
This allows to not have to write a `.book` configuration file for a
2016-12-31 00:00:31 +01:00
short story or an article. `crowbook -s foo.md` is rougly equivalent to having a book
2016-03-01 18:46:59 +01:00
configuration file containing:
```yaml
2016-03-01 18:46:59 +01:00
! foo.md
```
That is, the chapter heading (if any) won't be displayed in the output
documents (though they still appear in the TOC).
2016-12-31 00:00:31 +01:00
> Note that by default, using `--single` or `-s` sets the default LaTeX class
> of the book to `article` instead of `book`.
2016-09-09 22:57:30 +02:00
`--set`
-------
2016-03-01 21:41:23 +01:00
**usage**: `crowbook <BOOK> --set [KEY] [VALUE]...`
2016-10-21 19:36:50 +02:00
This argument takes a list of `KEY` `VALUE` pairs and allows setting or
overriding a book configuration option. All valid options in the
2016-02-22 03:26:39 +01:00
configuration files are valid as keys. For more information, see
2016-03-01 21:41:23 +01:00
[the configuration file](config.md).
2016-02-22 03:26:39 +01:00
### Examples ###
```bash
$ crowbook foo.book --set html.css style.css
```
will override the CSS for HTML generation (the `html.css` key) to the
file `style.css`.
```bash
2016-10-21 19:36:50 +02:00
$ crowbook foo.book --set author Foo title Bar
2016-02-22 03:26:39 +01:00
```
will override the book title to `Bar` and its author to `Foo`.
`--proofread`
-------------
2016-12-31 00:00:31 +01:00
**usage**: `crowbook --proofread <BOOK>`
(or `crowbook -p <BOOK>`)
Equivalent to `--set proofread true`. Enable proofreading. See [Proofreading](proofreading.md).
2016-02-23 23:20:21 +01:00
`--list-options`
----------------
**usage**: `crowbook --list-options`
(or `crowbook -l`)
2016-03-01 21:41:23 +01:00
Displays all the valid options to use, whether in a book configuration
file, with `--set`, or in an inline YAML block.
`--print-template`
------------------
**usage**: `crowbook --print-template template`
2016-11-19 00:34:05 +01:00
Prints the built-in template to stdout. Useful if you want to
customize the appearance of your document. E.g., if you want to modify
the CSS used for HTML rendering:
```bash
$ crowbook --print-template html.css > my_style.css
# edit my_style.css in your favourite editor
$ crowbook my.book --set html.css my_style.css
# or add "html.css: my_style.css" in my.book
```
2016-02-21 20:33:30 +01:00
`--verbose`
-----------
2016-02-23 23:20:21 +01:00
**usage**: `crowbook <BOOK> --verbose`
2016-02-21 20:33:30 +01:00
If this flag is set, Crowbook will print the warnings it detects while
2016-03-01 21:41:23 +01:00
parsing and rendering. These warnings are typically related to the
inclusion of non-local images, linking to Markdown files that are not
part of the book, and so on.
2016-02-21 20:33:30 +01:00
`--to`
------
2016-02-22 04:51:27 +01:00
**usage**: `crowbook <BOOK>--to [FORMAT]`
2016-02-21 20:33:30 +01:00
2016-02-22 04:51:27 +01:00
(or `crowbook <BOOK> -t [FORMAT]`)
2016-02-21 20:33:30 +01:00
Generate only the specified format. `FORMAT` must be either `epub`,
2016-12-31 00:00:31 +01:00
`pdf`, `html`, `html.dir`, `odt` or `tex`.
2016-02-21 20:33:30 +01:00
If an output file for the format is not specified in the book
configuration file, `crowbook` will fail to render PDF, ODT and EPUB,
2016-11-19 00:34:05 +01:00
whereas it will print HTML and TeX files on stdout. It is, however,
2016-02-21 20:33:30 +01:00
possible to specify a file with the `--output` option.
### Examples ###
```bash
2016-02-21 20:33:30 +01:00
crowbook --to html foo.book
```
will generate some HTML, and prints it either to the file specified by
2016-03-01 21:41:23 +01:00
`output.html` in `foo.book`, or to stdout if it is not specified.
2016-02-21 20:33:30 +01:00
```bash
2016-02-21 20:33:30 +01:00
crowbook --to pdf --output foo.pdf foo.book
```
2016-11-19 00:34:05 +01:00
will generate a `foo.pdf` file.
2016-02-21 20:33:30 +01:00
`--output`
---------
2016-02-22 04:51:27 +01:00
**usage**: `crowbook <BOOK> --to <FORMAT> --output <FILE> `
2016-02-21 20:33:30 +01:00
(or `crowbook -t <FORMAT> -o <FILE> <BOOK>`)
Specifies an output file. Only valid when `--to` is used.
2016-11-19 00:55:58 +01:00
`--lang`
----------
**usage**: `crowbook --lang <LANG>`
(or `crowbook -L <LANG>`)
Set the runtime language used by Crowbook. Currently, only a french
translation is available. By default, Crowbook uses the `LANG`
environment variable to determine which language to use, but this
option allows to override it (e.g. for operating systems that don't
use such an option, such as Windows).
### Example
`$ crowbook --lang fr --help`
will display Crowbook's help messages in french.
> Note that this argument has nothing to do with the `lang` option
> that you can set in the book configuration file, which specifies the
> language *of the book*. This argument specifies the language of the text messages
> that Crowbook will display while running.