Skip to content

Commit

Permalink
add optimize_printing to CLI, fix split order
Browse files Browse the repository at this point in the history
  • Loading branch information
Kneemund committed Aug 24, 2023
1 parent 45b0def commit d3446d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions crates/rnote-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub(crate) enum Commands {
/// Export without background pattern.
#[arg(short = 'p', long, action = ArgAction::SetTrue, global = true)]
no_pattern: bool,
/// Optimize the background and stroke colors for printing.
#[arg(long, action = ArgAction::SetTrue, global = true)]
optimize_printing: bool,
/// Inspect the result after the export is finished.{n}
/// Opens output folder when using "doc-pages" sub-command.
#[arg(long, action = ArgAction::SetTrue, global = true)]
Expand Down Expand Up @@ -174,6 +177,7 @@ pub(crate) async fn run() -> anyhow::Result<()> {
rnote_files,
no_background,
no_pattern,
optimize_printing,
on_conflict,
open,
export_command,
Expand All @@ -185,6 +189,7 @@ pub(crate) async fn run() -> anyhow::Result<()> {
rnote_files,
no_background,
no_pattern,
optimize_printing,
on_conflict,
open,
)
Expand Down
12 changes: 12 additions & 0 deletions crates/rnote-cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub(crate) async fn run_export(
rnote_files: Vec<PathBuf>,
no_background: bool,
no_pattern: bool,
optimize_printing: bool,
on_conflict: OnConflict,
open: bool,
) -> anyhow::Result<()> {
Expand Down Expand Up @@ -151,6 +152,7 @@ pub(crate) async fn run_export(
output_file,
no_background,
no_pattern,
optimize_printing,
)?;
match output_file {
Some(output_file) => {
Expand Down Expand Up @@ -292,6 +294,7 @@ fn apply_export_prefs(
output_file: Option<&PathBuf>,
no_background: bool,
no_pattern: bool,
optimize_printing: bool,
) -> anyhow::Result<()> {
match &export_commands {
ExportCommands::Doc {
Expand All @@ -303,6 +306,7 @@ fn apply_export_prefs(
file_args.output_format,
no_background,
no_pattern,
optimize_printing,
*page_order,
)?;
}
Expand All @@ -317,6 +321,7 @@ fn apply_export_prefs(
*output_format,
no_background,
no_pattern,
optimize_printing,
*page_order,
*bitmap_scalefactor,
*jpeg_quality,
Expand All @@ -334,6 +339,7 @@ fn apply_export_prefs(
file_args.output_format,
no_background,
no_pattern,
optimize_printing,
*bitmap_scalefactor,
*jpeg_quality,
*margin,
Expand Down Expand Up @@ -368,6 +374,7 @@ pub(crate) fn create_doc_export_prefs_from_args(
output_format: Option<DocExportFormat>,
no_background: bool,
no_pattern: bool,
optimize_printing: bool,
page_order: SplitOrder,
) -> anyhow::Result<DocExportPrefs> {
let format = match (output_file, output_format) {
Expand Down Expand Up @@ -397,6 +404,7 @@ pub(crate) fn create_doc_export_prefs_from_args(
export_format: format,
with_background: !no_background,
with_pattern: !no_pattern,
optimize_printing,
page_order,
};

Expand All @@ -418,6 +426,7 @@ pub(crate) fn create_doc_pages_export_prefs_from_args(
export_format: DocPagesExportFormat,
no_background: bool,
no_pattern: bool,
optimize_printing: bool,
page_order: SplitOrder,
bitmap_scalefactor: f64,
jpeg_quality: u8,
Expand All @@ -426,6 +435,7 @@ pub(crate) fn create_doc_pages_export_prefs_from_args(
export_format,
with_background: !no_background,
with_pattern: !no_pattern,
optimize_printing,
page_order,
bitmap_scalefactor,
jpeg_quality,
Expand All @@ -437,6 +447,7 @@ pub(crate) fn create_selection_export_prefs_from_args(
output_format: Option<SelectionExportFormat>,
no_background: bool,
no_pattern: bool,
optimize_printing: bool,
bitmap_scalefactor: f64,
jpeg_quality: u8,
margin: f64,
Expand Down Expand Up @@ -469,6 +480,7 @@ pub(crate) fn create_selection_export_prefs_from_args(
export_format: format,
with_background: !no_background,
with_pattern: !no_pattern,
optimize_printing,
bitmap_scalefactor,
jpeg_quality,
margin,
Expand Down
4 changes: 2 additions & 2 deletions crates/rnote-compose/src/splitorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ impl std::fmt::Display for SplitOrder {
f,
"{}",
match self {
SplitOrder::RowMajor => "horizontal",
SplitOrder::ColumnMajor => "vertical",
SplitOrder::RowMajor => "horizontal-first",
SplitOrder::ColumnMajor => "vertical-first",
}
)
}
Expand Down

0 comments on commit d3446d0

Please sign in to comment.