cliapp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -11
- data/cliapp.gemspec +10 -8
- data/lib/cliapp.rb +5 -11
- data/test/all.rb +18 -0
- metadata +4 -9
- data/Rakefile.rb +0 -9
- data/task/common-task.rb +0 -67
- data/task/release-task.rb +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc36e1395f591344e677cee0ce32742406474c28511b8718d5d19f46e7c44984
|
4
|
+
data.tar.gz: 0f5a532565538aa80be0cb78c65f131d3444ffd8ca8507224a95f76af4ff2406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3efedd274660695eea14e608d33679f71e808aecb04148d30b1c64fc22b1bf0b53666396bc1d57fadc8ed906747150efee754f2662f49dcc79e2a1d54b31cedf
|
7
|
+
data.tar.gz: 500be32f220b0247f131c9844dd94e323eac83cf6675a8a30033fc51e566600451ee523700a224c8940f6456d5ca4a94ef2f7c51cc3fc76684ef50caed90484c
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
CLIApp
|
2
2
|
======
|
3
3
|
|
4
|
-
($Version: 0.1.
|
4
|
+
($Version: 0.1.1 $)
|
5
5
|
|
6
6
|
CLIApp is a small framework for command-line application.
|
7
7
|
If you need to create a CLI app such as Git or Docker, CLIApp is one of the solutions.
|
@@ -45,7 +45,6 @@ app.global_options({
|
|
45
45
|
:version => [ "--version" , "print version number"],
|
46
46
|
:list => ["-l", "--list" , "list action names"],
|
47
47
|
})
|
48
|
-
APP = app
|
49
48
|
|
50
49
|
## 'hello' action
|
51
50
|
app.action("hello", "greeting message", {
|
@@ -71,17 +70,12 @@ GARBAGE_FILES = []
|
|
71
70
|
PRODUCT_FILES = []
|
72
71
|
|
73
72
|
## main
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
begin
|
74
|
+
app.run(*ARGV)
|
75
|
+
exit 0
|
77
76
|
rescue OptionParser::ParseError, CLIApp::ActionError => exc
|
78
77
|
$stderr.puts "[ERROR] #{exc.message}"
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
if __FILE__ == $0
|
83
|
-
status_code = main(ARGV)
|
84
|
-
exit status_code
|
78
|
+
exit 0
|
85
79
|
end
|
86
80
|
```
|
87
81
|
|
data/cliapp.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'cliapp'
|
5
|
-
spec.version = '$Version: 0.1.
|
5
|
+
spec.version = '$Version: 0.1.1 $'.split()[1]
|
6
6
|
spec.author = 'kwatch'
|
7
7
|
spec.email = 'kwatch@gmail.com'
|
8
8
|
spec.platform = Gem::Platform::RUBY
|
@@ -12,16 +12,18 @@ Gem::Specification.new do |spec|
|
|
12
12
|
A small framework for CLI Applications such as Git, Docker, NPM, etc.
|
13
13
|
END
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.files = Dir[
|
16
|
-
README.md MIT-LICENSE
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
spec.files = Dir[
|
16
|
+
"README.md", "MIT-LICENSE", "#{spec.name}.gemspec",
|
17
|
+
#"Rakefile.rb",
|
18
|
+
#"bin/*",
|
19
|
+
"lib/**/*.rb",
|
20
|
+
"test/**/*.rb",
|
21
|
+
#"task/**/*.rb",
|
22
|
+
]
|
21
23
|
spec.executables = []
|
22
24
|
spec.bindir = 'bin'
|
23
25
|
spec.require_path = 'lib'
|
24
|
-
spec.test_files = Dir['test/**/*_test.rb']
|
26
|
+
spec.test_files = ['test/all.rb'] # or: Dir['test/**/*_test.rb']
|
25
27
|
#spec.extra_rdoc_files = ['README.md', 'CHANGES.md']
|
26
28
|
|
27
29
|
spec.required_ruby_version = ">= 2.4"
|
data/lib/cliapp.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
##
|
5
5
|
## Command-Line Application Framework
|
6
6
|
##
|
7
|
-
## $Version: 0.1.
|
7
|
+
## $Version: 0.1.1 $
|
8
8
|
## $Copyright: copyright (c)2014 kwatch@gmail.com $
|
9
9
|
## $License: MIT License $
|
10
10
|
##
|
@@ -390,7 +390,6 @@ app.global_options({
|
|
390
390
|
:version => [ "--version" , "print version number"],
|
391
391
|
:list => ["-l", "--list" , "list action names"],
|
392
392
|
})
|
393
|
-
APP = app
|
394
393
|
|
395
394
|
## 'hello' action
|
396
395
|
app.action("hello", "greeting message", {
|
@@ -416,15 +415,10 @@ GARBAGE_FILES = []
|
|
416
415
|
PRODUCT_FILES = []
|
417
416
|
|
418
417
|
## main
|
419
|
-
|
420
|
-
|
421
|
-
|
418
|
+
begin
|
419
|
+
app.run(*ARGV)
|
420
|
+
exit 0
|
422
421
|
rescue OptionParser::ParseError, CLIApp::ActionError => exc
|
423
422
|
$stderr.puts "[ERROR] #{exc.message}"
|
424
|
-
|
425
|
-
end
|
426
|
-
|
427
|
-
if __FILE__ == $0
|
428
|
-
status_code = main(ARGV)
|
429
|
-
exit status_code
|
423
|
+
exit 1
|
430
424
|
end
|
data/test/all.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative './init'
|
5
|
+
|
6
|
+
path = File.dirname(__FILE__)
|
7
|
+
Dir.glob(path + '/**/*_test.rb').sort.each do |file|
|
8
|
+
require_relative file.sub(path, '.')
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
if __FILE__ == $0
|
13
|
+
require 'oktest'
|
14
|
+
Oktest.module_eval do
|
15
|
+
remove_const :REPORTER_CLASS
|
16
|
+
const_set :REPORTER_CLASS, Oktest::PlainReporter
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cliapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kwatch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oktest
|
@@ -34,12 +34,10 @@ extra_rdoc_files: []
|
|
34
34
|
files:
|
35
35
|
- MIT-LICENSE
|
36
36
|
- README.md
|
37
|
-
- Rakefile.rb
|
38
37
|
- cliapp.gemspec
|
39
38
|
- lib/cliapp.rb
|
40
|
-
- task/common-task.rb
|
41
|
-
- task/release-task.rb
|
42
39
|
- test/action_test.rb
|
40
|
+
- test/all.rb
|
43
41
|
- test/application_test.rb
|
44
42
|
- test/init.rb
|
45
43
|
- test/module_test.rb
|
@@ -68,7 +66,4 @@ signing_key:
|
|
68
66
|
specification_version: 4
|
69
67
|
summary: CLI Application Framework
|
70
68
|
test_files:
|
71
|
-
- test/
|
72
|
-
- test/util_test.rb
|
73
|
-
- test/action_test.rb
|
74
|
-
- test/application_test.rb
|
69
|
+
- test/all.rb
|
data/Rakefile.rb
DELETED
data/task/common-task.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
task :default => :help # or :test if you like
|
5
|
-
|
6
|
-
|
7
|
-
desc "list task names"
|
8
|
-
task :help do
|
9
|
-
system "rake -T"
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
desc "show how to release"
|
14
|
-
task :howto, [:version] do |t, args|
|
15
|
-
ver = args[:version] || ENV['version'] || "0.0.0"
|
16
|
-
zero_p = ver.end_with?('.0')
|
17
|
-
opt_b = zero_p ? " -b" : ""
|
18
|
-
puts <<"END"
|
19
|
-
How to release:
|
20
|
-
|
21
|
-
$ git diff # confirm that there is no changes
|
22
|
-
$ rake test
|
23
|
-
$ rake test:all # test on Ruby 2.x ~ 3.x
|
24
|
-
$ git checkout#{opt_b} rel-#{ver[0..-3]} # create or switch to release branch
|
25
|
-
$ vi CHANGES.md # if necessary
|
26
|
-
$ git add CHANGES.md # if necessary
|
27
|
-
$ git commit -m "Update 'CHANGES.md'" # if necessary
|
28
|
-
$ git log -1 # if necessary
|
29
|
-
$ cid=$(git log -1 | awk 'NR==1{print $2}') # if necessary
|
30
|
-
$ rake prepare[#{ver}] # update release number
|
31
|
-
$ git add -u . # add changes
|
32
|
-
$ git status -sb . # list files in staging area
|
33
|
-
$ git commit -m "Preparation for release #{ver}"
|
34
|
-
$ rake package # create a gem package
|
35
|
-
$ rake release[#{ver}] # upload to rubygems.org
|
36
|
-
$ git push -u origin
|
37
|
-
$ git tag | fgrep #{ver} # confirm release tag
|
38
|
-
$ git push --tags
|
39
|
-
$ git checkout - # back to main branch
|
40
|
-
$ git log -1 $cid # if necessary
|
41
|
-
$ git cherry-pick $cid # if necessary
|
42
|
-
|
43
|
-
END
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
desc "run test scripts"
|
48
|
-
task :test do
|
49
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), "lib")
|
50
|
-
sh "oktest test -sp"
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
desc "run test scripts on Ruby 2.x and 3.x"
|
55
|
-
task :'test:all' do
|
56
|
-
vs_home = ENV['VS_HOME'] or raise "$VS_HOME should be set."
|
57
|
-
defined?(RUBY_VERSIONS) or raise "RUBY_VERSIONS should be defined."
|
58
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), "lib")
|
59
|
-
RUBY_VERSIONS.each do |ver|
|
60
|
-
path_pat = "#{vs_home}/ruby/#{ver}.*/bin/ruby"
|
61
|
-
ruby_path = Dir.glob(path_pat).sort.last() or
|
62
|
-
raise "#{path_pat}: Not exist."
|
63
|
-
puts "\e[33m======== Ruby #{ver} ========\e[0m"
|
64
|
-
sh "#{ruby_path} -r oktest -e 'Oktest.main' -- test -sp" do end
|
65
|
-
puts ""
|
66
|
-
end
|
67
|
-
end
|
data/task/release-task.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
desc "update version number"
|
5
|
-
task :prepare, [:version] do |t, args|
|
6
|
-
version = version_number_required(args, :prepare)
|
7
|
-
spec = load_gemspec_file(SPECFILE)
|
8
|
-
edit(spec.files) {|s|
|
9
|
-
s.gsub(/\$Version\:.*?\$/, "$Version\: #{version} $") \
|
10
|
-
.gsub(/\$Version\$/, version)
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
desc "create gem package"
|
16
|
-
task :package do
|
17
|
-
sh "gem build #{SPECFILE}"
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
desc "upload gem to rubygems.org"
|
22
|
-
task :release, [:version] => :package do |t, args|
|
23
|
-
version = version_number_required(args, :release)
|
24
|
-
spec = load_gemspec_file(SPECFILE)
|
25
|
-
version == spec.version.to_s or
|
26
|
-
raise "Version in gemspec file (#{spec.version}) is different from #{version}"
|
27
|
-
gemfile = "#{PROJECT}-#{version}.gem"
|
28
|
-
print "*** Are you sure to upload #{gemfile}? [y/N]: "
|
29
|
-
answer = $stdin.gets().strip()
|
30
|
-
if answer =~ /\A[yY]/
|
31
|
-
sh "git tag v#{version}"
|
32
|
-
#sh "git tag rel-#{version}"
|
33
|
-
sh "gem push #{gemfile}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
##
|
39
|
-
## helpers
|
40
|
-
##
|
41
|
-
|
42
|
-
def edit(*filepaths)
|
43
|
-
filepaths.flatten.each do |fpath|
|
44
|
-
next if ! File.file?(fpath)
|
45
|
-
File.open(fpath, 'r+b:utf-8') do |f|
|
46
|
-
s = f.read()
|
47
|
-
new_s = yield s
|
48
|
-
if new_s != s
|
49
|
-
f.rewind()
|
50
|
-
f.truncate(0)
|
51
|
-
f.write(new_s)
|
52
|
-
puts "[Change] #{fpath}"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def load_gemspec_file(gemspec_file)
|
59
|
-
require 'rubygems'
|
60
|
-
return Gem::Specification::load(gemspec_file)
|
61
|
-
end
|
62
|
-
|
63
|
-
def version_number_required(args, task_name)
|
64
|
-
version = args[:version] || ENV['version']
|
65
|
-
unless version
|
66
|
-
$stderr.puts <<"END"
|
67
|
-
##
|
68
|
-
## ERROR: rake #{task_name}: requires 'version=X.X.X' option.
|
69
|
-
## For example:
|
70
|
-
## $ rake #{task_name} version=1.0.0
|
71
|
-
##
|
72
|
-
END
|
73
|
-
errmsg = "rake #{task_name}: requires 'version=X.X.X' option."
|
74
|
-
raise ArgumentError.new(errmsg)
|
75
|
-
end
|
76
|
-
return version
|
77
|
-
end
|