aro 0.1.2 → 0.1.4
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/.gitignore +6 -0
- data/.release +20 -0
- data/.ruby-version +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +105 -0
- data/LICENSE +21 -0
- data/README.md +70 -0
- data/Rakefile +5 -0
- data/aro.gemspec +30 -0
- data/bin/aro +7 -37
- data/bin/cli/config.rb +223 -0
- data/bin/cli/constants.rb +4 -2
- data/bin/cli/create.rb +8 -3
- data/bin/cli/deck.rb +63 -42
- data/bin/cli.rb +39 -0
- data/checksums/aro-0.1.4.gem.sha512 +1 -0
- data/lib/aro/create.rb +18 -19
- data/lib/aro/{database.rb → db.rb} +22 -28
- data/lib/aro/i18n.rb +8 -10
- data/lib/aro/prompt.rb +4 -0
- data/lib/aro/version.rb +2 -2
- data/lib/aro.rb +10 -7
- data/lib/models/deck.rb +124 -57
- data/lib/models/log.rb +8 -1
- data/locale/en.usage.yml +33 -10
- data/locale/en.yml +50 -14
- data/pkg/aro-0.1.0.gem +0 -0
- data/pkg/aro-0.1.1.gem +0 -0
- data/pkg/aro-0.1.2.gem +0 -0
- data/pkg/aro-0.1.3.gem +0 -0
- data/pkg/aro-0.1.4.gem +0 -0
- data/tasks/console.rake +8 -0
- data/tasks/make.rake +4 -0
- metadata +22 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a276927c911f1781041e6d5c274c1611f0a23a948edb9b0fb6bc17518d22eee5
|
|
4
|
+
data.tar.gz: 415a4ad29297c5c8815127fb4bae7c5dc97f4f8eb12cda4aacf2235997cb895e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a91cb814964c27d4aa6c53aea311dc530ecd897d4534f19b3295ad8954c7611268102b8113dc4ecaea52d23fb975dbf890bcfbcfc575727741c497942f3ea36f
|
|
7
|
+
data.tar.gz: b8270db12a879b8738d014f748929641d234234f61cbba5cc351907319d5616bfef2ae1f58616827930673703258841c2ee6c70d732ab247ae87941cf1bf0073
|
data/.gitignore
ADDED
data/.release
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# helper script for consistency when doing releases
|
|
2
|
+
|
|
3
|
+
# start on latest develop branch
|
|
4
|
+
|
|
5
|
+
# 1) update version and release notes (manually)
|
|
6
|
+
# 2) test and build
|
|
7
|
+
# $ rake make
|
|
8
|
+
# 3) build checksum
|
|
9
|
+
# $ rake build:checksum
|
|
10
|
+
# 4) create a commit
|
|
11
|
+
# 5) generate tag
|
|
12
|
+
# tag message format:
|
|
13
|
+
# vx.x.x
|
|
14
|
+
# <release_note_text>
|
|
15
|
+
# $ gitaga vx.x.x && gush tag vx.x.x
|
|
16
|
+
# 6) push develop
|
|
17
|
+
# 7) pull request develop -> master & merge
|
|
18
|
+
# 8) checkout and pull master
|
|
19
|
+
# 9) publish to rubygems
|
|
20
|
+
# $ gem push pkg/aro-x.x.x.gem
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-3.4.7
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
aro (0.1.3)
|
|
5
|
+
activerecord (~> 8.1, >= 8.1.1)
|
|
6
|
+
i18n (~> 1.14, >= 1.14.7)
|
|
7
|
+
sqlite3 (~> 2.8, >= 2.8.0)
|
|
8
|
+
tty-prompt (~> 0.23.1, >= 0.23.1)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
activemodel (8.1.1)
|
|
14
|
+
activesupport (= 8.1.1)
|
|
15
|
+
activerecord (8.1.1)
|
|
16
|
+
activemodel (= 8.1.1)
|
|
17
|
+
activesupport (= 8.1.1)
|
|
18
|
+
timeout (>= 0.4.0)
|
|
19
|
+
activesupport (8.1.1)
|
|
20
|
+
base64
|
|
21
|
+
bigdecimal
|
|
22
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
23
|
+
connection_pool (>= 2.2.5)
|
|
24
|
+
drb
|
|
25
|
+
i18n (>= 1.6, < 2)
|
|
26
|
+
json
|
|
27
|
+
logger (>= 1.4.2)
|
|
28
|
+
minitest (>= 5.1)
|
|
29
|
+
securerandom (>= 0.3)
|
|
30
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
31
|
+
uri (>= 0.13.1)
|
|
32
|
+
base64 (0.3.0)
|
|
33
|
+
bigdecimal (3.3.1)
|
|
34
|
+
concurrent-ruby (1.3.5)
|
|
35
|
+
connection_pool (2.5.4)
|
|
36
|
+
diff-lcs (1.6.2)
|
|
37
|
+
drb (2.2.3)
|
|
38
|
+
i18n (1.14.7)
|
|
39
|
+
concurrent-ruby (~> 1.0)
|
|
40
|
+
json (2.16.0)
|
|
41
|
+
logger (1.7.0)
|
|
42
|
+
minitest (5.26.1)
|
|
43
|
+
pastel (0.8.0)
|
|
44
|
+
tty-color (~> 0.5)
|
|
45
|
+
rake (13.3.1)
|
|
46
|
+
rspec (3.13.2)
|
|
47
|
+
rspec-core (~> 3.13.0)
|
|
48
|
+
rspec-expectations (~> 3.13.0)
|
|
49
|
+
rspec-mocks (~> 3.13.0)
|
|
50
|
+
rspec-core (3.13.6)
|
|
51
|
+
rspec-support (~> 3.13.0)
|
|
52
|
+
rspec-expectations (3.13.5)
|
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
|
+
rspec-support (~> 3.13.0)
|
|
55
|
+
rspec-mocks (3.13.7)
|
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
57
|
+
rspec-support (~> 3.13.0)
|
|
58
|
+
rspec-support (3.13.6)
|
|
59
|
+
securerandom (0.4.1)
|
|
60
|
+
sqlite3 (2.8.0-aarch64-linux-gnu)
|
|
61
|
+
sqlite3 (2.8.0-aarch64-linux-musl)
|
|
62
|
+
sqlite3 (2.8.0-arm-linux-gnu)
|
|
63
|
+
sqlite3 (2.8.0-arm-linux-musl)
|
|
64
|
+
sqlite3 (2.8.0-arm64-darwin)
|
|
65
|
+
sqlite3 (2.8.0-x86-linux-gnu)
|
|
66
|
+
sqlite3 (2.8.0-x86-linux-musl)
|
|
67
|
+
sqlite3 (2.8.0-x86_64-darwin)
|
|
68
|
+
sqlite3 (2.8.0-x86_64-linux-gnu)
|
|
69
|
+
sqlite3 (2.8.0-x86_64-linux-musl)
|
|
70
|
+
timeout (0.4.4)
|
|
71
|
+
tty-color (0.6.0)
|
|
72
|
+
tty-cursor (0.7.1)
|
|
73
|
+
tty-prompt (0.23.1)
|
|
74
|
+
pastel (~> 0.8)
|
|
75
|
+
tty-reader (~> 0.8)
|
|
76
|
+
tty-reader (0.9.0)
|
|
77
|
+
tty-cursor (~> 0.7)
|
|
78
|
+
tty-screen (~> 0.8)
|
|
79
|
+
wisper (~> 2.0)
|
|
80
|
+
tty-screen (0.8.2)
|
|
81
|
+
tzinfo (2.0.6)
|
|
82
|
+
concurrent-ruby (~> 1.0)
|
|
83
|
+
uri (1.1.1)
|
|
84
|
+
wisper (2.0.1)
|
|
85
|
+
|
|
86
|
+
PLATFORMS
|
|
87
|
+
aarch64-linux-gnu
|
|
88
|
+
aarch64-linux-musl
|
|
89
|
+
arm-linux-gnu
|
|
90
|
+
arm-linux-musl
|
|
91
|
+
arm64-darwin
|
|
92
|
+
x86-linux-gnu
|
|
93
|
+
x86-linux-musl
|
|
94
|
+
x86_64-darwin
|
|
95
|
+
x86_64-linux-gnu
|
|
96
|
+
x86_64-linux-musl
|
|
97
|
+
|
|
98
|
+
DEPENDENCIES
|
|
99
|
+
aro!
|
|
100
|
+
bundler (~> 2.7, >= 2.7.2)
|
|
101
|
+
rake (~> 13.3, >= 13.3.1)
|
|
102
|
+
rspec (~> 3.13, >= 3.13.2)
|
|
103
|
+
|
|
104
|
+
BUNDLED WITH
|
|
105
|
+
2.7.2
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2025 Scot Reichman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
6
|
+
software and associated documentation files (the “Software”), to deal in the Software
|
|
7
|
+
without restriction, including without limitation the rights to use, copy, modify,
|
|
8
|
+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all copies
|
|
13
|
+
or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
16
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
17
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
18
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
19
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
20
|
+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# aro
|
|
2
|
+
>__a cli for tarot__ - follow the way of the aro eht.
|
|
3
|
+
|
|
4
|
+
##### __current version:__
|
|
5
|
+
[](https://badge.fury.io/rb/aro)
|
|
6
|
+
|
|
7
|
+
aro is a command line interface that allows you to manage multiple tarot decks.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
$ gem install aro
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### use
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
$ aro -h
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
[usage documentation](https://raw.githubusercontent.com/i2097i/aro/refs/heads/master/locale/en.usage.yml)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
[card definitions](https://raw.githubusercontent.com/i2097i/aro/refs/heads/master/locale/en.cards.yml)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### develop
|
|
29
|
+
|
|
30
|
+
[rubygems.org guides](https://guides.rubygems.org)
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
# the Rakefile contains bundler's gem_tasks,
|
|
34
|
+
# which are used for gem development.
|
|
35
|
+
|
|
36
|
+
# Rakefile
|
|
37
|
+
require "bundler/gem_tasks"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# list tasks
|
|
42
|
+
$ rake --tasks
|
|
43
|
+
|
|
44
|
+
# build gem
|
|
45
|
+
$ rake build
|
|
46
|
+
|
|
47
|
+
# build and install
|
|
48
|
+
$ rake install
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### test
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
$ rspec
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### pre-commit hook:
|
|
58
|
+
```bash
|
|
59
|
+
: cat .git/hooks/pre-commit
|
|
60
|
+
#!/bin/sh
|
|
61
|
+
|
|
62
|
+
echo "running pre-commit hooks"
|
|
63
|
+
echo "exec rspec -f d -o ./spec/spec.log"
|
|
64
|
+
exec rspec -f d -o ./spec/spec.log
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
[license](http://opensource.org/licenses/MIT)
|
|
68
|
+
[issues](https://github.com/i2097i/aro/issues)
|
|
69
|
+
|
|
70
|
+
>aro by i2097i is copyright (2025)
|
data/Rakefile
ADDED
data/aro.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require :aro.to_s
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "aro"
|
|
7
|
+
spec.version = Aro::VERSION
|
|
8
|
+
spec.authors = ["i2097i"]
|
|
9
|
+
spec.email = ["i2097i@hotmail.com"]
|
|
10
|
+
spec.description = "a cli for tarot."
|
|
11
|
+
spec.summary = "follow the way of the aro eht."
|
|
12
|
+
spec.homepage = "https://github.com/i2097i/aro"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files`.split("\n").reject{|f| f.match(%r{^(spec)/})}
|
|
16
|
+
spec.bindir = "bin"
|
|
17
|
+
spec.executables = ["aro"]
|
|
18
|
+
spec.require_paths = ["lib", "bin/cli"]
|
|
19
|
+
|
|
20
|
+
# development gems
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.7", ">= 2.7.2"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 13.3", ">= 13.3.1"
|
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.13", ">= 3.13.2"
|
|
24
|
+
|
|
25
|
+
# runtime gems
|
|
26
|
+
spec.add_runtime_dependency "i18n", "~> 1.14", ">= 1.14.7"
|
|
27
|
+
spec.add_runtime_dependency "activerecord", "~> 8.1", ">= 8.1.1"
|
|
28
|
+
spec.add_runtime_dependency "sqlite3", "~> 2.8", ">= 2.8.0"
|
|
29
|
+
spec.add_runtime_dependency "tty-prompt", "~> 0.23.1", ">= 0.23.1"
|
|
30
|
+
end
|
data/bin/aro
CHANGED
|
@@ -10,50 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
[
|
|
15
|
-
:cli,
|
|
16
|
-
].each do |dir|
|
|
17
|
-
Dir[
|
|
18
|
-
File.join(
|
|
19
|
-
__dir__,
|
|
20
|
-
dir.to_s,
|
|
21
|
-
:"**/*.rb".to_s
|
|
22
|
-
)
|
|
23
|
-
].each { |file| require file}
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# set environment variable
|
|
27
|
-
ENV[:ARO_ENV.to_s] = :production.to_s
|
|
28
|
-
# ENV[:ARO_ENV.to_s] = :development.to_s
|
|
13
|
+
require_relative :cli.to_s
|
|
29
14
|
|
|
30
15
|
# todo: add tab completion using abbrev gem
|
|
31
16
|
# https://stackoverflow.com/a/11627931
|
|
32
17
|
|
|
33
|
-
# todo: response formats
|
|
34
|
-
# text (default)
|
|
35
|
-
# json
|
|
36
|
-
#
|
|
37
|
-
|
|
38
18
|
module CLI
|
|
39
|
-
|
|
40
|
-
if CLI::LOAD_DECK_ACTIONS.keys.map{|k| k.downcase.to_sym}.include?(ARGV[0]&.to_sym)
|
|
41
|
-
# enable deck shortcut (skip typing deck while in-game)
|
|
42
|
-
ARGV0 = :deck
|
|
43
|
-
ARGV1 = ARGV[0]&.to_sym
|
|
44
|
-
ARGV2 = ARGV[1]&.to_sym
|
|
45
|
-
else
|
|
46
|
-
# default
|
|
47
|
-
ARGV0 = ARGV[0]&.to_sym
|
|
48
|
-
ARGV1 = ARGV[1]&.to_sym
|
|
49
|
-
ARGV2 = ARGV[2]&.to_sym
|
|
50
|
-
end
|
|
51
|
-
|
|
52
19
|
if CLI::FLAGS[:VERSION].include?(CLI::ARGV0)
|
|
53
|
-
Aro::P.
|
|
20
|
+
Aro::P.say(Aro::VERSION)
|
|
54
21
|
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
55
22
|
end
|
|
56
23
|
|
|
24
|
+
# initialize config
|
|
25
|
+
CLI::Config.instance
|
|
26
|
+
|
|
57
27
|
# cli parser
|
|
58
28
|
case CLI::ARGV0
|
|
59
29
|
when :create
|
|
@@ -62,7 +32,7 @@ module CLI
|
|
|
62
32
|
CLI::deck
|
|
63
33
|
else
|
|
64
34
|
unless Aro::Mancy.game.nil? || CLI::FLAGS[:HELP].include?(CLI::ARGV0)
|
|
65
|
-
Aro::P.
|
|
35
|
+
Aro::P.say(I18n.t("cli.messages.welcome", name: "#{Aro::Mancy.name}.game.show"))
|
|
66
36
|
Aro::Mancy.game.show
|
|
67
37
|
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
68
38
|
end
|
|
@@ -70,5 +40,5 @@ module CLI
|
|
|
70
40
|
CLI::usage
|
|
71
41
|
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
72
42
|
end
|
|
73
|
-
|
|
43
|
+
|
|
74
44
|
end
|
data/bin/cli/config.rb
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
module CLI
|
|
2
|
+
class Config
|
|
3
|
+
include Singleton
|
|
4
|
+
|
|
5
|
+
VAR_PREFIX = :ARO_CONFIG_
|
|
6
|
+
|
|
7
|
+
CONFIG_FILE = :".config".to_s
|
|
8
|
+
CONFIG_FILE_PATH = "#{Aro::Db.base_aro_dir(Aro::Db.get_name_from_namefile)}/#{CLI::Config::CONFIG_FILE}"
|
|
9
|
+
|
|
10
|
+
INTS = {
|
|
11
|
+
O: 0,
|
|
12
|
+
I: 1,
|
|
13
|
+
VII: 7,
|
|
14
|
+
XXII: 22,
|
|
15
|
+
MMXCVII: Aro::Mancy::I2097I[1..4].to_i,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
# possible formats
|
|
19
|
+
#
|
|
20
|
+
# example usage:
|
|
21
|
+
# CLI::Config::FORMATS[:TEXT]
|
|
22
|
+
FORMATS = {
|
|
23
|
+
TEXT: :text,
|
|
24
|
+
JSON: :json,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# possible dimensions
|
|
28
|
+
#
|
|
29
|
+
# example usage:
|
|
30
|
+
# CLI::Config::DMS[:DEV_TAROT]
|
|
31
|
+
DMS = {
|
|
32
|
+
DEV_TAROT: :dev_tarot,
|
|
33
|
+
RUBY_FACOT: :ruby_facot,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# types used in definition
|
|
37
|
+
#
|
|
38
|
+
# example usage:
|
|
39
|
+
# CLI::Config::DEF_TYPES[:INT][:validator].call(unvalid, CLI::Config::DEF[:DIMENSION])
|
|
40
|
+
DEF_TYPES = {
|
|
41
|
+
INT: {
|
|
42
|
+
name: :int,
|
|
43
|
+
description: I18n.t("cli.config.type_int_description"),
|
|
44
|
+
validator: Proc.new{|unvalid, deff, key|
|
|
45
|
+
CLI::Config.def_valid?(deff, key) &&
|
|
46
|
+
CLI::Config.int_valid?(unvalid) &&
|
|
47
|
+
unvalid.to_i <= deff[:min] &&
|
|
48
|
+
unvalid.to_i >= deff[:max]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
VALUES: {
|
|
52
|
+
name: :values,
|
|
53
|
+
description: I18n.t("cli.config.type_values_description"),
|
|
54
|
+
validator: Proc.new{|unvalid, deff, key|
|
|
55
|
+
CLI::Config.def_valid?(deff, key) &&
|
|
56
|
+
deff[:possible_values].keys.include?(unvalid.to_sym)
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# adapts I18n translations to generate bash environment vars.
|
|
62
|
+
#
|
|
63
|
+
# example usage:
|
|
64
|
+
# CLI::Config::DEF[:Z_MAX]
|
|
65
|
+
DEF = {
|
|
66
|
+
FORMAT: {
|
|
67
|
+
type: :values,
|
|
68
|
+
description: I18n.t(
|
|
69
|
+
"cli.config.format_description",
|
|
70
|
+
possible_values: CLI::Config::FORMATS.values.join(", ")
|
|
71
|
+
),
|
|
72
|
+
value: :text,
|
|
73
|
+
possible_values: {
|
|
74
|
+
text: I18n.t("cli.config.text_format_description"),
|
|
75
|
+
json: I18n.t("cli.config.json_format_description")
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
DIMENSION: {
|
|
79
|
+
type: :values,
|
|
80
|
+
description: I18n.t(
|
|
81
|
+
"cli.config.dimension_description",
|
|
82
|
+
possible_values: CLI::Config::DMS.values.join(", ")
|
|
83
|
+
),
|
|
84
|
+
value: :dev_tarot,
|
|
85
|
+
possible_values: {
|
|
86
|
+
dev_tarot: I18n.t("cli.config.dimension_dev_tarot_description"),
|
|
87
|
+
ruby_facot: I18n.t("cli.config.dimension_ruby_facot_description"),
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
# not implemented. replace Aro::Deck::DRAW_COUNT with this
|
|
91
|
+
# DRAW_COUNT: {
|
|
92
|
+
# type: :int,
|
|
93
|
+
# description: I18n.t(
|
|
94
|
+
# "cli.config.draw_count_description",
|
|
95
|
+
# min: CLI::Config::INTS[:I],
|
|
96
|
+
# max: CLI::Config::INTS[:XXII],
|
|
97
|
+
# ),
|
|
98
|
+
# value: CLI::Config::INTS[:VII],
|
|
99
|
+
# min: CLI::Config::INTS[:I],
|
|
100
|
+
# max: CLI::Config::INTS[:XXII],
|
|
101
|
+
# },
|
|
102
|
+
Z: {
|
|
103
|
+
type: :int,
|
|
104
|
+
description: I18n.t(
|
|
105
|
+
"cli.config.z_description",
|
|
106
|
+
min: CLI::Config::INTS[:I],
|
|
107
|
+
max: CLI::Config::INTS[:MMXCVII],
|
|
108
|
+
),
|
|
109
|
+
value: CLI::Config::INTS[:I],
|
|
110
|
+
min: CLI::Config::INTS[:I],
|
|
111
|
+
max: CLI::Config::INTS[:MMXCVII],
|
|
112
|
+
},
|
|
113
|
+
Z_MAX: {
|
|
114
|
+
type: :int,
|
|
115
|
+
description: I18n.t(
|
|
116
|
+
"cli.config.z_max_description",
|
|
117
|
+
min: CLI::Config::INTS[:I],
|
|
118
|
+
max: CLI::Config::INTS[:XXII],
|
|
119
|
+
),
|
|
120
|
+
value: CLI::Config::INTS[:VII],
|
|
121
|
+
min: CLI::Config::INTS[:I],
|
|
122
|
+
max: CLI::Config::INTS[:XXII],
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
# ...
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
def generate_config
|
|
129
|
+
# todo: localize generated config text
|
|
130
|
+
Aro::P.say(I18n.t("cli.config.generating_default_config", name: CLI::Config::CONFIG_FILE_PATH))
|
|
131
|
+
File.open(CLI::Config::CONFIG_FILE_PATH, "w+") do |file|
|
|
132
|
+
file.write("# #{Aro::Mancy::PS1} configuration file.\n")
|
|
133
|
+
file.write("# this file was auto generated by the aro cli.\n")
|
|
134
|
+
Aro::Mancy::OS.times do
|
|
135
|
+
file.write("#\n")
|
|
136
|
+
end
|
|
137
|
+
file.write("# CLI::Config::DEF_TYPES\n")
|
|
138
|
+
file.write("# describes the possible types of variables.\n")
|
|
139
|
+
CLI::Config::DEF_TYPES.each{|k, v|
|
|
140
|
+
file.write("# #{k}: #{v[:description]}\n")
|
|
141
|
+
}
|
|
142
|
+
Aro::Mancy::OS.times do
|
|
143
|
+
file.write("#\n")
|
|
144
|
+
end
|
|
145
|
+
file.write("# CLI::Config::DEF\n")
|
|
146
|
+
file.write("# define & expose an aro bash api via ENV variables.\n")
|
|
147
|
+
file.write("# modifying them in this file will change aro's behavior.\n")
|
|
148
|
+
Aro::Mancy::OS.times do
|
|
149
|
+
file.write("#\n")
|
|
150
|
+
end
|
|
151
|
+
CLI::Config::DEF.each{|k, v|
|
|
152
|
+
var_name = CLI::Config.var_key_with_suffix(k)
|
|
153
|
+
file.write("# [#{var_name}]\n")
|
|
154
|
+
file.write("# => #{I18n.t("cli.config.def_type")}: #{v[:type]}\n")
|
|
155
|
+
case v[:type]
|
|
156
|
+
when CLI::Config::DEF_TYPES[:INT][:name]
|
|
157
|
+
file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
|
|
158
|
+
file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
|
|
159
|
+
when CLI::Config::DEF_TYPES[:VALUES][:name]
|
|
160
|
+
file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
|
|
161
|
+
v[:possible_values].each{|name, description|
|
|
162
|
+
file.write("# => #{name} - #{description}\n")
|
|
163
|
+
}
|
|
164
|
+
end
|
|
165
|
+
file.write("export #{var_name}=#{v[:value]}\n\n")
|
|
166
|
+
}
|
|
167
|
+
file.write("\n")
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def initialize
|
|
172
|
+
return unless Aro::Mancy.is_aro_dir?
|
|
173
|
+
unless File.exist?(CLI::Config::CONFIG_FILE_PATH)
|
|
174
|
+
generate_config
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
source_config
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def self.def_valid?(deff, key)
|
|
181
|
+
deff == CLI::Config::DEF[key]
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def self.int_valid?(unvalid)
|
|
185
|
+
return !unvalid.nil? && (
|
|
186
|
+
unvalid.kind_of?(Integer) ||
|
|
187
|
+
("0" != unvalid && unvalid.respond_to?(:to_i))
|
|
188
|
+
)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def self.var_value_with_suffix(suffix)
|
|
192
|
+
ENV[CLI::Config.var_key_with_suffix(suffix)]
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def self.var_key_with_suffix(suffix)
|
|
196
|
+
"#{CLI::Config::VAR_PREFIX}#{suffix}"
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def source_config
|
|
200
|
+
invalid_defs = validate_config
|
|
201
|
+
Aro::P.say(I18n.t("cli.config.sourcing_config", name: CLI::Config::CONFIG_FILE_PATH))
|
|
202
|
+
system("source #{CLI::Config::CONFIG_FILE_PATH}")
|
|
203
|
+
CLI::Config::DEF.keys.each{|dfk|
|
|
204
|
+
next if invalid_defs.include?(dfk)
|
|
205
|
+
Aro::P.say("$#{CLI::Config.var_key_with_suffix(dfk)}=#{CLI::Config.var_value_with_suffix(dfk)}")
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# todo: set all invalid_refs to default in ENV
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def validate_config
|
|
212
|
+
invalid_defs = []
|
|
213
|
+
CLI::Config::DEF.each{|k, v|
|
|
214
|
+
var_value = CLI::Config.var_value_with_suffix(k)
|
|
215
|
+
is_valid = CLI::Config::DEF_TYPES[v[:type].to_s.upcase.to_sym][:validator]
|
|
216
|
+
.call(var_value, v, k)
|
|
217
|
+
invalid_defs << k unless is_valid
|
|
218
|
+
}
|
|
219
|
+
invalid_defs
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
end
|
|
223
|
+
end
|
data/bin/cli/constants.rb
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
module CLI
|
|
12
12
|
|
|
13
13
|
FLAGS = {
|
|
14
|
-
HELP:
|
|
15
|
-
|
|
14
|
+
HELP: [:"-h", :"--help"],
|
|
15
|
+
SHOW_COUNT: [:"-n", :"--count"],
|
|
16
|
+
SHOW_ORDER: [:"-o", :"--order"],
|
|
17
|
+
VERSION: [:"-v", :"--version"],
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
EXIT_CODES = {
|
data/bin/cli/create.rb
CHANGED
|
@@ -10,8 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
module CLI
|
|
12
12
|
def self.create
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Aro::
|
|
13
|
+
CLI::Aroface.exit_error_missing_args! if CLI::ARGV1.nil?
|
|
14
|
+
name = CLI::ARGV1&.to_s
|
|
15
|
+
Aro::P.say(I18n.t("cli.messages.creation_attempt", name: name))
|
|
16
|
+
if Aro::Create.new(name).initialized
|
|
17
|
+
Aro::P.say(I18n.t("cli.messages.creation_success", name: name))
|
|
18
|
+
else
|
|
19
|
+
Aro::P.say(I18n.t("cli.messages.creation_failure", name: name))
|
|
20
|
+
end
|
|
16
21
|
end
|
|
17
22
|
end
|