Skip to content

Commit 03e4ffd

Browse files
author
Yasuhiro Asaka
committed
Added version option to commands
1 parent cd7f239 commit 03e4ffd

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

Diff for: Manifest.txt

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ README.txt
44
Rakefile
55
bin/docx2html
66
bin/docx2xml
7-
lib/version.rb
87
lib/ydocx.rb
98
lib/ydocx/builder.rb
109
lib/ydocx/document.rb

Diff for: README.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
== Usage
1515

16-
* Usage: /usr/local/bin/docx2html file [options]
17-
-f, --format Format of style and chapter {(fi|fachinfo)|(pl|plain)}, default is FI.
16+
* Usage: bin/docx2html file [options]
17+
-f, --format Format of style and chapter {(fi|fachinfo)|(pi|patinfo)|(pl|plain)|none}, default fachinfo.
1818
-h, --help Display this help message.
19+
-v, --version Show version.
1920

2021
== Using the great libraries
2122

Diff for: lib/version.rb

-6
This file was deleted.

Diff for: lib/ydocx.rb

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
require 'ydocx/document'
55

66
module YDocx
7+
VERSION = '1.0.7'
78
end

Diff for: lib/ydocx/command.rb

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env ruby
22
# encoding: utf-8
33

4-
require 'ydocx/document'
4+
require 'ydocx'
55

66
module YDocx
77
class Command
88
class << self
9-
@@help = /^\-(h|\-help)$/u
10-
@@format = /^\-(f|\-format)$/u
9+
@@help = /^\-(h|\-help)$/u
10+
@@format = /^\-(f|\-format)$/u
11+
@@version = /^\-(v|\-version)$/u
1112
def error(message='')
1213
puts message
1314
puts "see `#{self.command} --help`"
@@ -19,8 +20,9 @@ def command
1920
def help
2021
banner = <<-BANNER
2122
Usage: #{$0} file [options]
22-
-f, --format Format of style and chapter {(fi|fachinfo)|(pl|plain)|none}, default fachinfo.
23+
-f, --format Format of style and chapter {(fi|fachinfo)|(pi|patinfo)|(pl|plain)|none}, default fachinfo.
2324
-h, --help Display this help message.
25+
-v, --version Show version.
2426
BANNER
2527
puts banner
2628
exit
@@ -36,6 +38,8 @@ def run(action=:to_html)
3638
argv = ARGV.dup
3739
if argv.empty? or argv[0] =~ @@help
3840
self.help
41+
elsif argv[0] =~ @@version
42+
self.version
3943
else
4044
file = argv.shift
4145
path = File.expand_path(file)
@@ -76,6 +80,10 @@ def run(action=:to_html)
7680
end
7781
end
7882
end
83+
def version
84+
puts "#{self.command}: version #{VERSION}"
85+
exit
86+
end
7987
end
8088
end
8189
end

0 commit comments

Comments
 (0)