bin/svgcode in svgcode-0.4.0 vs bin/svgcode in svgcode-0.6.0
- old
+ new
@@ -1,43 +1,6 @@
#!/usr/bin/env ruby
require 'bundler/setup'
-require 'svgcode'
-require 'thor'
+require 'svgcode/cli'
-
-class SVGCLI < Thor
- desc 'parse SVG_PATH [--out OUT_PATH] [--comments]',
- 'parses an SVG file to a G-code file'
- option :out_path
- option :comments, type: :boolean
- long_desc <<-LONGDESC
- `svgcode parse ~/Desktop/img.svg` will save the G-code file as
- '~/Desktop/img.ngc'.
-
- Optionally set the --out-path flag to save the G-code file elsewhere
- \x5 e.g. `svgcode parse ~/Documents/img.svg --out-path ~/Desktop/gcode.nc`
-
- Optionally pass the --comments flag to print SVG IDs as comments
- \x5 e.g. `svgcode parse --comments ~/Desktop/img.svg`
- LONGDESC
- def parse(in_path)
- in_path = File.expand_path(in_path)
- raise "#{in_path} is not readable" unless File.readable?(in_path)
- svg_str = File.read(in_path)
-
- out_path =
- if options[:out_path].nil?
- in_path.gsub(/\.svg\Z/i, '.ngc')
- else
- File.expand_path(options[:out_path])
- end
-
- opts = { comments: options[:comments] }
- File.open(out_path, 'w') { |f| f << Svgcode.parse(svg_str, opts) }
-
- puts "G-code written to #{out_path}"
- end
-end
-
-
-SVGCLI.start(ARGV)
+Svgcode::CLI.start(ARGV)