1
0
Fork 0
mirror of https://github.com/lise-henry/crowbook synced 2024-05-23 13:16:16 +02:00
crowbook/guide/arguments.md

240 lines
5.8 KiB
Markdown
Raw Normal View History

2016-02-21 20:33:30 +01:00
Arguments
=========
2017-06-05 17:53:34 +02:00
Crowbook can take a number of arguments, generally in the form:
```bash
crowbook [OPTIONS] [BOOK]
```
2016-02-21 20:33:30 +01:00
2017-06-05 17:53:34 +02:00
The most important argument is obviously the book
2016-11-19 00:34:05 +01:00
configuration file. It is mandatory in most cases: if you don't
2017-06-05 17:53:34 +02:00
pass it, Crowbook will simply display an error. In a normal use case this is
2017-07-14 19:40:02 +02:00
the only argument you'll need to pass, as most options will be set in this configuration file.
2016-02-21 20:33:30 +01:00
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
2017-07-14 19:40:02 +02:00
(or `crowbook [BOOK] -c file_1.md file_2.md ...`)
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
```bash
2017-07-14 19:40:02 +02:00
crowbook foo.book --create chapter_1.md chapter_2.md chapter_3.md
2016-02-21 20:33:30 +01:00
```
2017-07-14 19:40:02 +02:00
will thus generate a file `foo.book` containing:
2016-02-21 20:33:30 +01:00
```yaml
2016-02-21 20:33:30 +01:00
author: Your name
title: Your title
lang: en
2017-07-14 19:40:02 +02:00
## Output formats
2016-02-21 20:33:30 +01:00
# Uncomment and fill to generate files
# output.html: some_file.html
# output.epub: some_file.epub
# output.pdf: some_file.pdf
2017-07-14 19:40:02 +02:00
# Or uncomment the following to generate PDF, HTML and EPUB files based on this file's name
# output: [pdf, epub, html]
# Uncomment and fill to set cover image (for EPUB)
2016-02-21 20:33:30 +01:00
# cover: some_cover.png
2017-07-14 19:40:02 +02:00
## List of chapters
+ chapter_1.md
+ chapter_2.md
+ chapter_3.md
2016-02-21 20:33:30 +01:00
```
while
```bash
2017-07-14 19:40:02 +02:00
crowbook --create chapter_1.md chapter_2.md chapter_3.md
```
will print the same result, but to stdout (without creating a file).
2016-03-01 18:46:59 +01:00
`--single`
----------
2017-06-05 17:53:34 +02:00
**Usage**: `crowbook --single <FILE>`
2016-03-01 18:46:59 +01:00
(or `crowbook -s <FILE>`)
2017-07-14 19:40:02 +02:00
This argument allows you 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
2017-07-14 19:40:02 +02:00
output: [html, epub, pdf]
2016-03-01 18:46:59 +01:00
---
2017-06-05 17:53:34 +02:00
Content of the story in Markdown.
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`
-------
2017-06-05 17:53:34 +02: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).
```bash
2017-07-14 19:40:02 +02:00
$ crowbook foo.book --set tex.paper.size a4paper
2016-02-22 03:26:39 +01:00
```
2017-06-05 17:53:34 +02:00
will override the paper size for PDF generation.
2016-02-22 03:26:39 +01:00
2016-02-23 23:20:21 +01:00
`--list-options`
----------------
2017-06-05 17:53:34 +02:00
**Usage**: `crowbook --list-options`
2016-02-23 23:20:21 +01:00
(or `crowbook -l`)
2017-07-14 19:40:02 +02:00
Displays all the valid options that can be used, whether in a book configuration
2016-03-01 21:41:23 +01:00
file, with `--set`, or in an inline YAML block.
`--print-template`
------------------
2017-06-05 17:53:34 +02:00
**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
```
2017-07-14 18:37:37 +02:00
`--stats`
2017-07-14 19:40:02 +02:00
------------
2017-07-14 18:37:37 +02:00
**Usage**: `crowbook --stats <BOOK>`
(or `crowbook -S <BOOK>`)
Display some statistics (word and character counts) about the book.
2017-07-14 19:40:02 +02:00
`--proofread`
-------------
**Usage**: `crowbook --proofread <BOOK>`
(or `crowbook -p <BOOK>`)
Equivalent to `--set proofread true`. Enable proofreading. See [Proofreading](proofreading.md).
2016-02-21 20:33:30 +01:00
`--verbose`
-----------
2017-06-05 17:53:34 +02:00
**Usage**: `crowbook <BOOK> --verbose`
2016-02-21 20:33:30 +01:00
2017-06-05 17:53:34 +02:00
If this flag is set, Crowbook will print more warnings it detects while
parsing and rendering.
2016-02-21 20:33:30 +01:00
`--to`
------
2017-06-05 17:53:34 +02: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`
---------
2017-06-05 17:53:34 +02: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`
----------
2017-06-05 17:53:34 +02:00
**Usage**: `crowbook --lang <LANG>`
2016-11-19 00:55:58 +01:00
(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`
2017-06-05 17:53:34 +02:00
will display Crowbook's help message in french.
2016-11-19 00:55:58 +01:00
> 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
2017-06-05 17:53:34 +02:00
> that Crowbook will display while running, but has no effect on the generated documents.
2016-11-19 00:55:58 +01:00