bashly 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c219a4bf3f32f47434d1a855a620ea62caaafe336a8647e8ef84529eb7023b8
4
- data.tar.gz: d18b7f6bdfeb43fc4a27fb9e5f617d1c0c9c6f5783f5c7dc1df8f6eff575c8ab
3
+ metadata.gz: 58a2804698490f003611b4f607614fef9995bea16f426c6d56d527d78b770a29
4
+ data.tar.gz: 24a4c1d97b45332e424fc6932092225bab7b3ade618f5eec5e9c187ca91389ac
5
5
  SHA512:
6
- metadata.gz: 38cf3b1d1c49c447f0e2817b57cb03362e528cefe22dc0f4d9c1dcfcb7b52859c034bc012bfb7ec769b6c94801c102bfe74d9c336e0dbc8ee060027c10b1b242
7
- data.tar.gz: e64ced05cc15cd4cb66cc2dc6696cb522db87843c9fc8826d69500cfb1aafb8aa3ad13ccf36bca806ce262cece7c30763229d82f297bbf471ee71ca5807eaaec
6
+ metadata.gz: 0e62c14ede0d0295e01411cd946859a21413e50b43313f850ea494c4ed5dafe6f402b914dfc8f682c3abc8e38d9004917dbd654d78f8983b961f2f35228e97e4
7
+ data.tar.gz: '00309d231db02bb61fe7d9ae2c95d9d615888830a6a95c2815cda9e8b08fa4dd73e6ccc0f0127bf46a467deee4888297975f421a2a1e0c80fa5b23d871124726'
data/lib/bashly/cli.rb CHANGED
@@ -9,13 +9,14 @@ module Bashly
9
9
  header: 'Bashly - Bash CLI Generator',
10
10
  footer: "Help: m`bashly COMMAND --help`\nDocs: bu`https://bashly.dannyb.co`"
11
11
 
12
- runner.route 'init', to: Commands::Init
13
- runner.route 'preview', to: Commands::Preview
14
- runner.route 'validate', to: Commands::Validate
15
- runner.route 'generate', to: Commands::Generate
16
- runner.route 'add', to: Commands::Add
17
- runner.route 'doc', to: Commands::Doc
18
- runner.route 'shell', to: Commands::Shell unless ENV['BASHLY_SHELL']
12
+ runner.route 'init', to: Commands::Init
13
+ runner.route 'preview', to: Commands::Preview
14
+ runner.route 'validate', to: Commands::Validate
15
+ runner.route 'generate', to: Commands::Generate
16
+ runner.route 'add', to: Commands::Add
17
+ runner.route 'doc', to: Commands::Doc
18
+ runner.route 'completions', to: Commands::Completions
19
+ runner.route 'shell', to: Commands::Shell unless ENV['BASHLY_SHELL']
19
20
 
20
21
  runner
21
22
  end
@@ -0,0 +1,56 @@
1
+ module Bashly
2
+ module Commands
3
+ class Completions < Base
4
+ summary 'Install bash completions for bashly itself'
5
+ help 'Display the bash completions script or install it directly to your bash completions directory'
6
+
7
+ usage 'bashly completions [--install --uninstall]'
8
+ usage 'bashly completions (-h|--help)'
9
+
10
+ option '-i --install', 'Install the completions script to your bash completions directory'
11
+ option '-u --uninstall', 'Uninstall the completions script from your bash completions directory'
12
+
13
+ def run
14
+ if args['--install']
15
+ install_completions
16
+ elsif args['--uninstall']
17
+ uninstall_completions
18
+ else
19
+ puts script
20
+ end
21
+ end
22
+
23
+ def installer
24
+ @installer ||= Completely::Installer.new program: 'bashly', script_path: script_path
25
+ end
26
+
27
+ private
28
+
29
+ def install_completions
30
+ success = installer.install force: true
31
+ raise Error, "Failed running command:\nnb`#{installer.install_command_string}`" unless success
32
+
33
+ say 'Completions installed'
34
+ say "Source: m`#{installer.script_path}`"
35
+ say "Target: m`#{installer.target_path}`"
36
+ say 'Restart your session for the changes to take effect'
37
+ end
38
+
39
+ def uninstall_completions
40
+ success = installer.uninstall
41
+ raise Error, "Failed running command:\nnb`#{installer.uninstall_command_string}`" unless success
42
+
43
+ say 'Completions uninstalled'
44
+ say 'Restart your session for the changes to take effect'
45
+ end
46
+
47
+ def script_path
48
+ @script_path ||= asset('completions/bashly-completions.bash')
49
+ end
50
+
51
+ def script
52
+ @script ||= asset_content('completions/bashly-completions.bash')
53
+ end
54
+ end
55
+ end
56
+ end
@@ -42,10 +42,8 @@ module Bashly
42
42
  Filewatcher.new([Settings.source_dir]).watch do
43
43
  reset
44
44
  generate
45
-
46
45
  rescue Bashly::ConfigurationError => e
47
46
  say! "rib` #{e.class} `\n#{e.message}"
48
-
49
47
  ensure
50
48
  quiet_say "g`waiting`\n"
51
49
  end
@@ -19,7 +19,7 @@ module Bashly
19
19
  terminal = MisterBin::Terminal.new runner, {
20
20
  autocomplete: autocomplete,
21
21
  show_usage: true,
22
- prompt: "\n\e[33m\e[1mbashly\e[0m > ",
22
+ prompt: "\n$> bashly ",
23
23
  }
24
24
 
25
25
  terminal.on('help') { runner.run %w[--help] }
@@ -0,0 +1,24 @@
1
+ # Completions for bashly executable
2
+
3
+ This directory contains templates for generating bash completions.
4
+
5
+ ## For developers
6
+
7
+ From the root directory of the repository, run `run completions`. This will:
8
+
9
+ 1. Read the `completely.yaml.gtx` template
10
+ 2. Write the `completely.yaml` file (to allow testing with completely)
11
+ 3. Generate the `bashly-completions.bash` file
12
+ 4. Copy it to the completions directory with `sudo`
13
+
14
+ Note that for production use, only the `bashly-completions.bash` is used.
15
+
16
+ ## For users
17
+
18
+ Install completions in one of two ways:
19
+
20
+ 1. Run `bashly completions --install`. This will make a best effort to copy
21
+ the completions script to your completions directory.
22
+ 2. If the above fails, run `bashly completions > out.bash`, then copy the file
23
+ manually to your completions directory (or simply get the
24
+ `bashly-completions.bash` from this directory).
@@ -0,0 +1,115 @@
1
+ # bashly completion -*- shell-script -*-
2
+
3
+ # This bash completions script was generated by
4
+ # completely (https://github.com/dannyben/completely)
5
+ # Modifying it manually is not recommended
6
+
7
+ _bashly_completions_filter() {
8
+ local words="$1"
9
+ local cur=${COMP_WORDS[COMP_CWORD]}
10
+ local result=()
11
+
12
+ if [[ "${cur:0:1}" == "-" ]]; then
13
+ echo "$words"
14
+
15
+ else
16
+ for word in $words; do
17
+ [[ "${word:0:1}" != "-" ]] && result+=("$word")
18
+ done
19
+
20
+ echo "${result[*]}"
21
+
22
+ fi
23
+ }
24
+
25
+ _bashly_completions() {
26
+ local cur=${COMP_WORDS[COMP_CWORD]}
27
+ local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
28
+ local compline="${compwords[*]}"
29
+
30
+ case "$compline" in
31
+ 'generate'*'--env')
32
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "development production")" -- "$cur" )
33
+ ;;
34
+
35
+ 'generate'*'-e')
36
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "development production")" -- "$cur" )
37
+ ;;
38
+
39
+ 'completions'*)
40
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --install -i")" -- "$cur" )
41
+ ;;
42
+
43
+ 'validate'*)
44
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --verbose -v")" -- "$cur" )
45
+ ;;
46
+
47
+ 'generate'*)
48
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --env --force --quiet --upgrade --watch --wrap -e -f -q -r -u -w")" -- "$cur" )
49
+ ;;
50
+
51
+ 'preview'*)
52
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h")" -- "$cur" )
53
+ ;;
54
+
55
+ 'g'*'--env')
56
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "development production")" -- "$cur" )
57
+ ;;
58
+
59
+ 'shell'*)
60
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h")" -- "$cur" )
61
+ ;;
62
+
63
+ 'init'*)
64
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --minimal -m")" -- "$cur" )
65
+ ;;
66
+
67
+ 'g'*'-e')
68
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "development production")" -- "$cur" )
69
+ ;;
70
+
71
+ 'add'*)
72
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --force --list --source -f -l -s colors completions completions_script completions_yaml config help hooks lib settings strings test validations yaml")" -- "$cur" )
73
+ ;;
74
+
75
+ 'doc'*)
76
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --index -i arg arg.allowed arg.default arg.help arg.name arg.repeatable arg.required arg.validate command command.alias command.args command.catch_all command.commands command.completions command.default command.dependencies command.environment_variables command.examples command.expose command.extensible command.filename command.filters command.flags command.footer command.function command.group command.help command.name command.private command.version environment_variable environment_variable.default environment_variable.help environment_variable.name environment_variable.private environment_variable.required flag flag.allowed flag.arg flag.completions flag.conflicts flag.default flag.help flag.long flag.private flag.repeatable flag.required flag.short flag.validate")" -- "$cur" )
77
+ ;;
78
+
79
+ 'i'*)
80
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --minimal -m")" -- "$cur" )
81
+ ;;
82
+
83
+ 'p'*)
84
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h")" -- "$cur" )
85
+ ;;
86
+
87
+ 'v'*)
88
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --verbose -v")" -- "$cur" )
89
+ ;;
90
+
91
+ 'g'*)
92
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --env --force --quiet --upgrade --watch --wrap -e -f -q -r -u -w")" -- "$cur" )
93
+ ;;
94
+
95
+ 'a'*)
96
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --force --list --source -f -l -s colors completions completions_script completions_yaml config help hooks lib settings strings test validations yaml")" -- "$cur" )
97
+ ;;
98
+
99
+ 'c'*)
100
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --install -i")" -- "$cur" )
101
+ ;;
102
+
103
+ 's'*)
104
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h")" -- "$cur" )
105
+ ;;
106
+
107
+ *)
108
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_bashly_completions_filter "--help -h --version -v init preview validate generate add doc completions shell")" -- "$cur" )
109
+ ;;
110
+
111
+ esac
112
+ } &&
113
+ complete -F _bashly_completions bashly
114
+
115
+ # ex: filetype=sh
@@ -0,0 +1,155 @@
1
+ bashly:
2
+ - --help
3
+ - -h
4
+ - --version
5
+ - -v
6
+ - init
7
+ - preview
8
+ - validate
9
+ - generate
10
+ - add
11
+ - doc
12
+ - completions
13
+ - shell
14
+
15
+ bashly init: &init
16
+ - --help
17
+ - -h
18
+ - --minimal
19
+ - -m
20
+
21
+ bashly i: *init
22
+
23
+ bashly preview: &preview
24
+ - --help
25
+ - -h
26
+
27
+ bashly p: *preview
28
+
29
+ bashly validate: &validate
30
+ - --help
31
+ - -h
32
+ - --verbose
33
+ - -v
34
+
35
+ bashly v: *validate
36
+
37
+ bashly generate: &generate
38
+ - --help
39
+ - -h
40
+ - --env
41
+ - --force
42
+ - --quiet
43
+ - --upgrade
44
+ - --watch
45
+ - --wrap
46
+ - -e
47
+ - -f
48
+ - -q
49
+ - -r
50
+ - -u
51
+ - -w
52
+
53
+ bashly g: *generate
54
+
55
+ bashly generate*--env: &env
56
+ - development
57
+ - production
58
+
59
+ bashly generate*-e: *env
60
+ bashly g*--env: *env
61
+ bashly g*-e: *env
62
+
63
+ bashly add: &add
64
+ - --help
65
+ - -h
66
+ - --force
67
+ - --list
68
+ - --source
69
+ - -f
70
+ - -l
71
+ - -s
72
+ - colors
73
+ - completions
74
+ - completions_script
75
+ - completions_yaml
76
+ - config
77
+ - help
78
+ - hooks
79
+ - lib
80
+ - settings
81
+ - strings
82
+ - test
83
+ - validations
84
+ - yaml
85
+
86
+ bashly a: *add
87
+
88
+ bashly doc: &doc
89
+ - --help
90
+ - -h
91
+ - --index
92
+ - -i
93
+ - arg
94
+ - arg.allowed
95
+ - arg.default
96
+ - arg.help
97
+ - arg.name
98
+ - arg.repeatable
99
+ - arg.required
100
+ - arg.validate
101
+ - command
102
+ - command.alias
103
+ - command.args
104
+ - command.catch_all
105
+ - command.commands
106
+ - command.completions
107
+ - command.default
108
+ - command.dependencies
109
+ - command.environment_variables
110
+ - command.examples
111
+ - command.expose
112
+ - command.extensible
113
+ - command.filename
114
+ - command.filters
115
+ - command.flags
116
+ - command.footer
117
+ - command.function
118
+ - command.group
119
+ - command.help
120
+ - command.name
121
+ - command.private
122
+ - command.version
123
+ - environment_variable
124
+ - environment_variable.default
125
+ - environment_variable.help
126
+ - environment_variable.name
127
+ - environment_variable.private
128
+ - environment_variable.required
129
+ - flag
130
+ - flag.allowed
131
+ - flag.arg
132
+ - flag.completions
133
+ - flag.conflicts
134
+ - flag.default
135
+ - flag.help
136
+ - flag.long
137
+ - flag.private
138
+ - flag.repeatable
139
+ - flag.required
140
+ - flag.short
141
+ - flag.validate
142
+
143
+ bashly completions: &completions
144
+ - --help
145
+ - -h
146
+ - --install
147
+ - -i
148
+
149
+ bashly c: *completions
150
+
151
+ bashly shell: &shell
152
+ - --help
153
+ - -h
154
+
155
+ bashly s: *shell
@@ -0,0 +1,85 @@
1
+ > bashly:
2
+ = help_flags
3
+ > - --version
4
+ > - -v
5
+ commands.each do |command|
6
+ = "- #{command}"
7
+ end
8
+ >
9
+ > bashly init: &init
10
+ = help_flags
11
+ > - --minimal
12
+ > - -m
13
+ >
14
+ > bashly i: *init
15
+ >
16
+ > bashly preview: &preview
17
+ = help_flags
18
+ >
19
+ > bashly p: *preview
20
+ >
21
+ > bashly validate: &validate
22
+ = help_flags
23
+ > - --verbose
24
+ > - -v
25
+ >
26
+ > bashly v: *validate
27
+ >
28
+ > bashly generate: &generate
29
+ = help_flags
30
+ > - --env
31
+ > - --force
32
+ > - --quiet
33
+ > - --upgrade
34
+ > - --watch
35
+ > - --wrap
36
+ > - -e
37
+ > - -f
38
+ > - -q
39
+ > - -r
40
+ > - -u
41
+ > - -w
42
+ >
43
+ > bashly g: *generate
44
+ >
45
+ > bashly generate*--env: &env
46
+ > - development
47
+ > - production
48
+ >
49
+ > bashly generate*-e: *env
50
+ > bashly g*--env: *env
51
+ > bashly g*-e: *env
52
+ >
53
+ > bashly add: &add
54
+ = help_flags
55
+ > - --force
56
+ > - --list
57
+ > - --source
58
+ > - -f
59
+ > - -l
60
+ > - -s
61
+ libs.each do |lib|
62
+ = "- #{lib}"
63
+ end
64
+ >
65
+ > bashly a: *add
66
+ >
67
+ > bashly doc: &doc
68
+ = help_flags
69
+ > - --index
70
+ > - -i
71
+ docs.each do |doc|
72
+ = "- #{doc}"
73
+ end
74
+ >
75
+ > bashly completions: &completions
76
+ = help_flags
77
+ > - --install
78
+ > - -i
79
+ >
80
+ > bashly c: *completions
81
+ >
82
+ > bashly shell: &shell
83
+ = help_flags
84
+ >
85
+ > bashly s: *shell
@@ -240,7 +240,7 @@ module Bashly
240
240
 
241
241
  # Returns true if one of the args is repeatable
242
242
  def repeatable_arg_exist?
243
- args.select(&:repeatable).any?
243
+ args.any?(&:repeatable)
244
244
  end
245
245
 
246
246
  # Returns an array of all the required Arguments
@@ -265,7 +265,7 @@ module Bashly
265
265
 
266
266
  # Returns true if one of the flags matches the provided short code
267
267
  def short_flag_exist?(flag)
268
- flags.select { |f| f.short == flag }.any?
268
+ flags.any? { |f| f.short == flag }
269
269
  end
270
270
 
271
271
  # Returns the summary string
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bashly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.5'
39
+ version: 0.6.1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.5'
46
+ version: 0.6.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: filewatcher
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -127,12 +127,17 @@ files:
127
127
  - lib/bashly/cli.rb
128
128
  - lib/bashly/commands/add.rb
129
129
  - lib/bashly/commands/base.rb
130
+ - lib/bashly/commands/completions.rb
130
131
  - lib/bashly/commands/doc.rb
131
132
  - lib/bashly/commands/generate.rb
132
133
  - lib/bashly/commands/init.rb
133
134
  - lib/bashly/commands/preview.rb
134
135
  - lib/bashly/commands/shell.rb
135
136
  - lib/bashly/commands/validate.rb
137
+ - lib/bashly/completions/README.md
138
+ - lib/bashly/completions/bashly-completions.bash
139
+ - lib/bashly/completions/completely.yaml
140
+ - lib/bashly/completions/completely.yaml.gtx
136
141
  - lib/bashly/concerns/asset_helper.rb
137
142
  - lib/bashly/concerns/completions.rb
138
143
  - lib/bashly/concerns/renderable.rb
@@ -263,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
268
  - !ruby/object:Gem::Version
264
269
  version: '0'
265
270
  requirements: []
266
- rubygems_version: 3.4.13
271
+ rubygems_version: 3.4.14
267
272
  signing_key:
268
273
  specification_version: 4
269
274
  summary: Bash Command Line Tool Generator