Commands

Using Draft’s commands is easy. In your terminal just use draft COMMAND. If you ever need additional help while using the tool, just use draft --help or draft COMMAND --help to get information on specific commands.

Commands can be broken out into three buckets:

  1. Create a project
  2. Format a project’s file content
  3. Maintain a project

Create

Create commands are helpful when first starting up a project (parse especially for legacy projects).

draft.cli.create_project(title)

Generates a project structure. The root file name will be the title but: lower case, spaces replaced with dashes, and only the first two words (minus articles like ‘and’, ‘of’, etc.)

Parameters:title (str) – Title for the project.
Returns:None
Usage:
>>> draft generate-project 'Catcher In The Rye'

Example file tree:

catcher-rye/
└─project/
│ └─Catcher In The Rye/
└─settings.yml
└─.gitignore
draft.cli.parse(filename)

Generates a project tree based on a Markdown formatted file. Useful for generating project trees based on legacy projects or an outline file.

Will automatically strip punctuation out of Markdown headers for folder names, but will preserve them in the ‘overrides’ section of settings.yml for use in compiling.

Parameters:filename (str) – Filename (i.e., not the full path) to be parsed (must include extension).
Returns:None
Usage:
>>> draft parse mobydick.md

Format

Format commands are used to change the way text is arranged within files.

draft.cli.split(filename=None)

Splits multi-line sentences into separate lines. Affects all project files unless filepath is passed as an argument.

Parameters:filename (str) – (optional) Filename (i.e., not the full path) to be parsed (must include extension).
Returns:None
Usage:
>>> draft split '01-Meeting Ishmael.md'
draft.cli.trim(filename=None)

Removes all duplicate spaces from text. Acts on every file in project unless filepath argument passed.

Parameters:filepath (str) – (optional) Filename (i.e., not the full path) to be parsed (must include extension).
Returns:None
Usage:
>>> draft trim '01-Meeting Ishmael.md'

Maintain

Maintain commands are used mostly as you are writing, organizing, and publishing your project.

draft.cli.sequence()

Resets indices in folders and files and resolves duplicates.

Usage:
>>> draft sequence

Note

The number of digits in each file/folder sequence is governed by the total number of items at that level. For example, if you have 5 sections and 150 scenes, your sections will sequence 1, 2, 3, 4, 5 and your scenes will sequence 001, 002, 003, etc.

draft.cli.stats()

Gets statistics from the project (e.g., word count, etc.)

Returns:word_count, scene_count, sub_chapter_count, chapter_count, section_count
Return type:int
Usage:
>>> draft stats
>>> Words: 54034
>>> Scenes: 67
>>> Sub-Chapters: 30
>>> Chapters: 10
>>> Sections: 3
draft.cli.compile()

Compiles the project into markdown and HTML documents.

Usage:
>>> draft compile
draft.cli.outline()

Generates a new project outline.

Usage:
>>> draft outline