polygon-art/src/context/commandline.rs

63 lines
1.6 KiB
Rust

use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt()]
/// Polygon Art command line interface
///
/// A Framework to draw images as background or to plot them
/// with your favorite plotter
pub struct Opt {
/// Output file
#[structopt(parse(from_os_str))]
pub output: PathBuf,
/// define width in pixels
#[structopt(long, default_value = "600")]
pub width: i32,
/// define height in pixels
#[structopt(long, default_value = "400")]
pub height: i32,
/// use a predefined format
#[structopt(
long,
conflicts_with="height",
conflicts_with="width",
possible_values=&["a3", "a4", "a5", "x220"]
)]
pub format: Option<String>,
/// change orientation
#[structopt(
long,
default_value="landscape",
possible_values=&["portrait", "landscape"]
)]
pub orientation: String,
/// define line size in pixels, all lines will be this thick
#[structopt(long, default_value = "1.0")]
pub line_size: f64,
/// output file format should be svg instead of png
#[structopt(long="type", possible_values=&["svg", "png"], default_value="png")]
pub output_type: String,
/// seed for the randomizer
#[structopt(long = "random")]
pub random_seed: Option<u64>,
/// seed for the randomizer based on date.
/// (must be ISO8601)
#[structopt(long = "random-date", conflicts_with = "random-seed", parse(try_from_str = iso8601::date))]
pub random_seed_date: Option<iso8601::Date>,
}
impl Opt {
pub fn get_command_line_arguments() -> Self {
Opt::from_args()
}
}