Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
Added --list-separator.
Browse files Browse the repository at this point in the history
Closes #113
  • Loading branch information
RazrFalcon committed Dec 18, 2017
1 parent 50cd053 commit 1b10bf6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http:https://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http:https://semver.org/).

## [Unreleased]
### Added
- `--list-separator`.

### Fixed
- Groups removing with transform and non-SVG child.
- Transform to path applying when a path has a style defined in a parent element.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ fern = "0.4"

[dependencies.svgdom]
# latest
# git = "https://github.com/RazrFalcon/libsvgdom.git"
git = "https://github.com/RazrFalcon/libsvgdom.git"
# branch = "devel"
# local copy
# path = "../svgdom"
# from crates
version = "0.9"
# version = "0.9"

[dependencies.error-chain]
version = "0.11"
Expand Down
1 change: 1 addition & 0 deletions data/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Output:
--properties-precision <NUM> Set properties numeric precision (1..12) [default: 6]
--transforms-precision <NUM> Set transform values numeric precision (1..12) [default: 8]
--paths-coordinates-precision <NUM> Set path's coordinates numeric precision (1..12) [default: 8]
--list-separator <SEPARATOR> Set number list separator [values: space, comma, comma-space] [default: space]
--indent <INDENT> Set XML nodes indent [values: none, 0, 1, 2, 3, 4, tabs] [default: none]

ARGS:
Expand Down
27 changes: 25 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ use clap::{
};

use svgdom::{
Indent,
ListSeparator,
ParseOptions,
WriteOptions,
WriteOptionsPaths,
Indent,
};

use {
Expand Down Expand Up @@ -104,6 +105,7 @@ pub enum Key {
PropertiesPrecision,
TransformsPrecision,
PathsCoordinatesPrecision,
ListSeparator,
Indent,

NoDefaults,
Expand Down Expand Up @@ -175,6 +177,7 @@ pub static KEYS: &'static KeysData<'static> = &KeysData(&[
"properties-precision",
"transforms-precision",
"paths-coordinates-precision",
"list-separator",
"indent",

"no-defaults",
Expand Down Expand Up @@ -294,6 +297,11 @@ pub fn prepare_app<'a, 'b>() -> App<'a, 'b> {
.arg(gen_precision!(Key::PropertiesPrecision, "6"))
.arg(gen_precision!(Key::TransformsPrecision, "8"))
.arg(gen_precision!(Key::PathsCoordinatesPrecision, "8"))
.arg(Arg::with_name(KEYS[Key::ListSeparator])
.long(KEYS[Key::ListSeparator])
.value_name("SEPARATOR")
.possible_values(&["space", "comma", "comma-space"])
.default_value("space"))
.arg(Arg::with_name(KEYS[Key::Indent])
.long(KEYS[Key::Indent])
.value_name("INDENT")
Expand Down Expand Up @@ -418,8 +426,15 @@ impl<'a> Flags<'a> {

pub fn gen_parse_options(args: &ArgMatches) -> ParseOptions {
let mut opt = ParseOptions {
parse_comments: true,
parse_declarations: true,
parse_unknown_elements: true,
parse_unknown_attributes: true,
parse_px_unit: false,
.. ParseOptions::default()
skip_unresolved_classes: true,
skip_invalid_attributes: false,
skip_invalid_css: false,
skip_paint_fallback: false,
};

let flags = Flags::new(args);
Expand Down Expand Up @@ -449,6 +464,7 @@ pub fn gen_write_options(args: &ArgMatches) -> WriteOptions {
use_implicit_lineto_commands: false,
},
simplify_transform_matrices: false,
list_separator: ListSeparator::Space,
};

let flags = Flags::new(args);
Expand All @@ -462,6 +478,13 @@ pub fn gen_write_options(args: &ArgMatches) -> WriteOptions {

flags.resolve(&mut opt.trim_hex_colors, Key::TrimColors);

opt.list_separator = match args.value_of(KEYS[Key::ListSeparator]).unwrap() {
"space" => ListSeparator::Space,
"comma" => ListSeparator::Comma,
"comma-space" => ListSeparator::CommaSpace,
_ => unreachable!(), // clap will validate the input.
};

opt.indent = match args.value_of(KEYS[Key::Indent]).unwrap() {
"none" => Indent::None,
"0" => Indent::Spaces(0),
Expand Down

0 comments on commit 1b10bf6

Please sign in to comment.