Skip to content

Commit

Permalink
Set default value for output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Aug 17, 2024
1 parent 44e1750 commit 5ec03c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ The desired document type can be set by calling the `.doctype` function within t
- `.doctype {slides}`
- `.doctype {paged}`

> [!NOTE]
> Make sure to set the output directory in order to save the output to file.
> This can be done by setting the command line argument `--out <dir>` or `-o <dir>`.
> [!TIP]
> If not set via the command line argument `--out <dir>` or `-o <dir>`,
> output files are saved into the `output` directory by default.
## Scripting

Expand Down
11 changes: 9 additions & 2 deletions cli/src/main/kotlin/eu/iamgio/quarkdown/cli/QuarkdownCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package eu.iamgio.quarkdown.cli
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.optional
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.file
Expand All @@ -11,6 +12,12 @@ import eu.iamgio.quarkdown.pipeline.error.BasePipelineErrorHandler
import eu.iamgio.quarkdown.pipeline.error.StrictPipelineErrorHandler
import java.io.File

/**
* Name of the default directory to save output files in.
* It can be overridden by the user.
*/
const val DEFAULT_OUTPUT_DIRECTORY = "output"

/**
* Main command of the Quarkdown CLI, that processes and executes a Quarkdown source file.
*/
Expand All @@ -27,13 +34,13 @@ class QuarkdownCommand : CliktCommand() {

/**
* Optional output directory.
* If not set, output files are not generated.
* If not set, the output is saved in [DEFAULT_OUTPUT_DIRECTORY].
*/
private val outputDirectory: File? by option("-o", "--out", help = "Output directory").file(
mustExist = false,
canBeFile = false,
canBeDir = true,
)
).default(File(DEFAULT_OUTPUT_DIRECTORY))

/**
* When enabled, the rendering stage produces pretty output code.
Expand Down

0 comments on commit 5ec03c0

Please sign in to comment.