power_stencil 0.8.13 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/etc/power_stencil.yaml +1 -0
- data/etc/templates/zsh_command_line_completion/_power_stencil.sh.erb +18 -8
- data/lib/power_stencil.rb +4 -0
- data/lib/power_stencil/command_processors/adm.rb +29 -1
- data/lib/power_stencil/dsl/completion.rb +37 -0
- data/lib/power_stencil/engine/directory_processor.rb +18 -1
- data/lib/power_stencil/initializer.rb +6 -1
- data/lib/power_stencil/plugins/command_line.rb +3 -1
- data/lib/power_stencil/ultra_command_line/command_line_manager.rb +35 -0
- data/lib/power_stencil/ultra_command_line/option_definition.rb +5 -0
- data/lib/power_stencil/ultra_command_line/providers_manager.rb +21 -0
- data/lib/power_stencil/ultra_command_line/sub_command.rb +12 -0
- data/lib/power_stencil/utils/completion.rb +19 -9
- data/lib/power_stencil/version.rb +1 -1
- data/power_stencil.gemspec +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 953c643a9a919791eeb8dc12c8e725c2a8ab80c6
|
4
|
+
data.tar.gz: 8231bae8f9f3d2fe16987b758ffcc8e22be3f295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfede811fa8dc0efc67e158abf08e93aac47fb327c6642fff344d6caa0bb7b908443ad31bc229c9b165ab3868c1f311adb63c7d24d168e5fbef98b09495634a4
|
7
|
+
data.tar.gz: 1b962bde64576cc9cb8a20f272a048289e42caf212d4fa63814c778fb672e1b0e137ff3dcedb3ecfab6a30488942f1db37e26eceb8b2e687a39156ec13419268
|
data/etc/power_stencil.yaml
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
# zsh shell completion script for <%= script_name %>
|
4
4
|
# To regenerate this file: '<%= script_name %> adm --zsh-completion'
|
5
|
-
# Generated
|
5
|
+
# Generated<%= timestamp %> by <%= script_name %> v<%= PowerStencil::VERSION %>
|
6
6
|
|
7
|
-
<% commands =
|
8
|
-
_<%= script_name %>() {
|
7
|
+
<% commands = context_commands -%>
|
8
|
+
_<%= script_name %>_first_level() {
|
9
9
|
local cmd
|
10
10
|
local <%= script_name %>_sub_commands
|
11
11
|
<%= script_name %>_sub_commands=(<%= commands.reject { |c| c.name.empty? }.sort { |a,b| a.name <=> b.name }.map(&:name).join ' ' %>)
|
@@ -21,7 +21,7 @@ _<%= script_name %>() {
|
|
21
21
|
(( $+functions[_<%= script_name %>_cmd_$cmd] )) && _<%= script_name %>_cmd_$cmd
|
22
22
|
else
|
23
23
|
_values : \
|
24
|
-
<%= continued_multilines(root_command
|
24
|
+
<%= continued_multilines(context_options(root_command commands).sort { |a,b| a.name <=> b.name }.map {|o| option_representation o}, number_spaces: 10) %>
|
25
25
|
fi
|
26
26
|
else
|
27
27
|
_values : \
|
@@ -33,7 +33,7 @@ _<%= script_name %>() {
|
|
33
33
|
<% end -%>
|
34
34
|
<%= command_representation command %> \
|
35
35
|
<% end -%>
|
36
|
-
<%= continued_multilines(root_command.
|
36
|
+
<%= continued_multilines(context_options(root_command).sort { |a,b| a.name <=> b.name }.map {|o| option_representation o}, number_spaces: 8) %>
|
37
37
|
fi
|
38
38
|
}
|
39
39
|
|
@@ -46,7 +46,7 @@ _<%= script_name %>_cmd_<%= command.name %>() {
|
|
46
46
|
_arguments -s : \
|
47
47
|
<%
|
48
48
|
command_param = default_command_param_type command
|
49
|
-
options_lines = command.
|
49
|
+
options_lines = context_options(command).sort { |a,b| a.name <=> b.name }.map {|o| option_representation o}
|
50
50
|
options_lines << command_param unless command_param.empty?
|
51
51
|
-%>
|
52
52
|
<%= continued_multilines(options_lines) %>
|
@@ -124,5 +124,15 @@ _power_stencil_do_nothing() {
|
|
124
124
|
return 1
|
125
125
|
}
|
126
126
|
|
127
|
-
|
128
|
-
_<%= script_name %>
|
127
|
+
|
128
|
+
_<%= script_name %>() {
|
129
|
+
if $( _within_power_stencil_project ); then
|
130
|
+
local project_root=$( _power_stencil_project_root )
|
131
|
+
if [ -f "${project_root}/.ps_project/<%= PowerStencil.config[:completion_target][:zsh][:project_completion_filename] %>" ]; then
|
132
|
+
. "${project_root}/.ps_project/<%= PowerStencil.config[:completion_target][:zsh][:project_completion_filename] %>"
|
133
|
+
fi
|
134
|
+
else
|
135
|
+
. "<%= File.expand_path(File.join PowerStencil.config[:completion_target][:zsh][:completion_dir], "_#{script_name}") %>"
|
136
|
+
fi
|
137
|
+
_<%= script_name %>_first_level "$@"
|
138
|
+
}
|
data/lib/power_stencil.rb
CHANGED
@@ -5,6 +5,10 @@ require 'dir_glob_ignore'
|
|
5
5
|
|
6
6
|
$DO_NOT_AUTOSTART_CLIMATIC=true
|
7
7
|
require 'climatic'
|
8
|
+
require 'power_stencil/ultra_command_line/command_line_manager'
|
9
|
+
require 'power_stencil/ultra_command_line/providers_manager'
|
10
|
+
require 'power_stencil/ultra_command_line/option_definition'
|
11
|
+
require 'power_stencil/ultra_command_line/sub_command'
|
8
12
|
|
9
13
|
require 'power_stencil/error'
|
10
14
|
require 'power_stencil/utils/os'
|
@@ -12,7 +12,35 @@ module PowerStencil
|
|
12
12
|
def execute
|
13
13
|
|
14
14
|
if config[:'zsh-completion']
|
15
|
-
|
15
|
+
target_dir = File.expand_path config[:completion_target][:zsh][:completion_dir]
|
16
|
+
script_name = 'power_stencil'
|
17
|
+
user_completion_script = File.join target_dir, "_#{script_name}"
|
18
|
+
begin
|
19
|
+
current_dir = Dir.pwd
|
20
|
+
Dir.mktmpdir 'completion_generation' do |tmpdir|
|
21
|
+
Dir.chdir tmpdir
|
22
|
+
generate_zsh_completion script_name, user_completion_script, false
|
23
|
+
end
|
24
|
+
ensure
|
25
|
+
Dir.chdir current_dir
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
project
|
30
|
+
shortname_project_completion_script = File.join config[:default_config_directory_name], config[:completion_target][:zsh][:project_completion_filename]
|
31
|
+
project.track_action_with_git("Adding project specific zsh completion file: '#{ shortname_project_completion_script }'.") do
|
32
|
+
project_completion_script = File.join project.project_config_root, config[:completion_target][:zsh][:project_completion_filename]
|
33
|
+
generate_zsh_completion script_name, project_completion_script, true
|
34
|
+
puts_and_logs "A specific completion has been generated for this project in '#{project_completion_script}'.", check_verbose: false
|
35
|
+
end
|
36
|
+
rescue
|
37
|
+
# Do not check errors. This is just to load project config...
|
38
|
+
logger.debug "Outside of a PowerStencil project... Not generating zsh project completion."
|
39
|
+
end
|
40
|
+
puts_and_logs "zsh global auto_completion has been installed in '#{user_completion_script}'.", check_verbose: false
|
41
|
+
puts
|
42
|
+
puts "You should ensure you have something like 'fpath=(#{target_dir} $fpath)' in your ~/.zshrc file..."
|
43
|
+
puts 'You may have to relog for changes to be applied.'
|
16
44
|
return
|
17
45
|
end
|
18
46
|
|
@@ -5,15 +5,52 @@ module PowerStencil
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
attr_accessor :script_name
|
8
|
+
attr_accessor :generating_project_completion
|
8
9
|
end
|
9
10
|
|
10
11
|
attr_reader :encountered_types
|
11
12
|
|
13
|
+
def timestamp
|
14
|
+
if generating_user_completion?
|
15
|
+
" on the #{Time.now}"
|
16
|
+
else
|
17
|
+
''
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
12
21
|
def initialize(universe)
|
13
22
|
super
|
14
23
|
@encountered_types = {}
|
15
24
|
end
|
16
25
|
|
26
|
+
def generating_project_completion?
|
27
|
+
self.class.generating_project_completion
|
28
|
+
end
|
29
|
+
|
30
|
+
def generating_user_completion?
|
31
|
+
!self.class.generating_project_completion
|
32
|
+
end
|
33
|
+
|
34
|
+
def context_commands
|
35
|
+
if generating_user_completion?
|
36
|
+
PowerStencil.command_line_manager.commands.select do |command|
|
37
|
+
command.providers.include? PowerStencil
|
38
|
+
end
|
39
|
+
else
|
40
|
+
PowerStencil.command_line_manager.commands
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def context_options(command)
|
45
|
+
if generating_user_completion?
|
46
|
+
command.options.select do |option|
|
47
|
+
option.providers.include? PowerStencil
|
48
|
+
end
|
49
|
+
else
|
50
|
+
command.options
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
17
54
|
def script_name
|
18
55
|
self.class.script_name
|
19
56
|
end
|
@@ -30,10 +30,27 @@ module PowerStencil
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
ensure
|
33
|
-
@
|
33
|
+
@files_not_to_rename = nil
|
34
34
|
@files_not_to_render = nil
|
35
35
|
end
|
36
36
|
|
37
|
+
|
38
|
+
def render_single_template_file(source_template, destination_file, main_entry_point: nil)
|
39
|
+
compiled_universe = root_universe.compile scenario: config[:scenario]
|
40
|
+
puts_and_logs 'Entities analysis completed.'
|
41
|
+
|
42
|
+
logger.info 'Generating target file...'
|
43
|
+
|
44
|
+
process_file source_template, destination_file,
|
45
|
+
compiled_universe,
|
46
|
+
overwrite_files: true,
|
47
|
+
main_entry_point: main_entry_point
|
48
|
+
ensure
|
49
|
+
@files_not_to_rename = nil
|
50
|
+
@files_not_to_render = nil
|
51
|
+
end
|
52
|
+
|
53
|
+
|
37
54
|
private
|
38
55
|
|
39
56
|
def detemplatized_file_name(filename, replacement_text)
|
@@ -55,14 +55,19 @@ module PowerStencil
|
|
55
55
|
describe: PowerStencil::CommandProcessors::Describe,
|
56
56
|
adm: PowerStencil::CommandProcessors::Adm
|
57
57
|
}.each do |command_name, processor|
|
58
|
-
|
58
|
+
command = command_line_manager.command_by_alias(command_name)
|
59
|
+
command_line_manager.register_processor command,
|
59
60
|
processor.new
|
61
|
+
command.add_provider self
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
65
|
def setup_climatic(cmd_line_args)
|
64
66
|
mngr = Climatic::ConfigLayers::CommandLineLayer.build_command_line_manager base_commands_definition_file
|
65
67
|
Climatic.bootstrap cmd_line_args: cmd_line_args, command_manager: mngr
|
68
|
+
mngr.commands.each do |command|
|
69
|
+
command.add_provider PowerStencil
|
70
|
+
end
|
66
71
|
begin
|
67
72
|
# Fix command line layer priority to allow a bigger number of plugins
|
68
73
|
config.command_line_layer.priority = 999
|
@@ -10,7 +10,9 @@ module PowerStencil
|
|
10
10
|
clm = PowerStencil.command_line_manager
|
11
11
|
plugin_definition[:processors].each do |processors_name, processor|
|
12
12
|
processor_class = Object.const_get processor
|
13
|
-
|
13
|
+
command = clm.command_by_alias(processors_name)
|
14
|
+
clm.register_processor command, processor_class.new
|
15
|
+
command.add_provider self
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class UltraCommandLine::Manager::Base
|
2
|
+
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def add_provider_for(command_or_option, provider)
|
6
|
+
providers = providers_for command_or_option
|
7
|
+
providers << provider unless providers.include? provider
|
8
|
+
end
|
9
|
+
|
10
|
+
def providers_for(command_or_option)
|
11
|
+
default_command_data = {options: {}, providers: []}
|
12
|
+
case command_or_option
|
13
|
+
when UltraCommandLine::Commands::SubCommand
|
14
|
+
sc = command_or_option
|
15
|
+
internal_provider_mapping[sc.name] ||= default_command_data
|
16
|
+
internal_provider_mapping[sc.name][:providers]
|
17
|
+
when UltraCommandLine::Commands::OptionDefinition
|
18
|
+
sco = command_or_option
|
19
|
+
internal_provider_mapping[sco.sub_command.name] ||= default_command_data
|
20
|
+
internal_provider_mapping[sco.sub_command.name][:options][sco.name] ||= []
|
21
|
+
internal_provider_mapping[sco.sub_command.name][:options][sco.name]
|
22
|
+
else
|
23
|
+
raise PowerStencil::Error, "Invalid command or option"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# private
|
28
|
+
|
29
|
+
def internal_provider_mapping
|
30
|
+
@internal_provider_mapping ||= {}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module UltraCommandLine
|
3
|
+
|
4
|
+
module ProvidersManager
|
5
|
+
|
6
|
+
def providers_manager
|
7
|
+
PowerStencil.command_line_manager.class
|
8
|
+
end
|
9
|
+
|
10
|
+
def providers
|
11
|
+
providers_manager.providers_for self
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_provider(provider)
|
15
|
+
providers_manager.add_provider_for self, provider
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -3,24 +3,34 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
module Completion
|
5
5
|
|
6
|
-
|
6
|
+
class FakeIgnoreList
|
7
|
+
attr_accessor :return_value
|
8
|
+
def ignore_file?(file)
|
9
|
+
return_value
|
10
|
+
end
|
11
|
+
end
|
7
12
|
|
8
|
-
|
13
|
+
include PowerStencil::Utils::DirectoryProcessor
|
9
14
|
|
10
|
-
|
11
|
-
config.executable_gem_layer[:file_renaming_patterns] = {'(.+)_power_stencil.sh.erb' => '\1_power_stencil' }
|
15
|
+
def generate_zsh_completion(script_name, target_file, generating_project_completion)
|
12
16
|
|
13
|
-
target_dir = File.expand_path config[:completion_target][:zsh][:completion_dir]
|
14
17
|
source_dir = File.join PowerStencil::Project::Paths.system_templates_templates_path, 'zsh_command_line_completion'
|
18
|
+
source_template = File.join source_dir, '_power_stencil.sh.erb'
|
15
19
|
|
16
20
|
engine = PowerStencil::Engine::InitEngine.new
|
17
21
|
engine.dsl = PowerStencil::Dsl::Completion
|
18
22
|
engine.dsl.script_name = script_name
|
19
|
-
engine.
|
23
|
+
engine.dsl.generating_project_completion = generating_project_completion
|
24
|
+
|
25
|
+
engine.instance_eval do
|
26
|
+
@files_not_to_rename = FakeIgnoreList.new
|
27
|
+
files_not_to_rename.return_value = true
|
28
|
+
@files_not_to_render = FakeIgnoreList.new
|
29
|
+
files_not_to_render.return_value = false
|
30
|
+
end
|
31
|
+
|
32
|
+
engine.render_single_template_file source_template, target_file
|
20
33
|
|
21
|
-
puts_and_logs "zsh auto_completion has been installed in '#{File.join target_dir, "_#{script_name}"}'.", check_verbose: false
|
22
|
-
puts "You should ensure you have something like 'fpath=(#{target_dir} $fpath)' in your ~/.zshrc file..."
|
23
|
-
puts 'You may have to relog for changes to be applied.'
|
24
34
|
end
|
25
35
|
|
26
36
|
end
|
data/power_stencil.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
|
28
|
-
spec.add_dependency 'climatic', '~> 0.2.
|
28
|
+
spec.add_dependency 'climatic', '~> 0.2.34'
|
29
29
|
spec.add_dependency 'dir_glob_ignore', '~> 0.3'
|
30
30
|
spec.add_dependency 'universe_compiler', '~> 0.5.5'
|
31
31
|
spec.add_dependency 'pry'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: power_stencil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent Briais
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.2.
|
61
|
+
version: 0.2.34
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.2.
|
68
|
+
version: 0.2.34
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: dir_glob_ignore
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,6 +282,10 @@ files:
|
|
282
282
|
- lib/power_stencil/system_entity_definitions/project_entity.rb
|
283
283
|
- lib/power_stencil/system_entity_definitions/simple_exec.rb
|
284
284
|
- lib/power_stencil/system_entity_definitions/source_provider.rb
|
285
|
+
- lib/power_stencil/ultra_command_line/command_line_manager.rb
|
286
|
+
- lib/power_stencil/ultra_command_line/option_definition.rb
|
287
|
+
- lib/power_stencil/ultra_command_line/providers_manager.rb
|
288
|
+
- lib/power_stencil/ultra_command_line/sub_command.rb
|
285
289
|
- lib/power_stencil/utils/completion.rb
|
286
290
|
- lib/power_stencil/utils/directory_processor.rb
|
287
291
|
- lib/power_stencil/utils/file_edit.rb
|
@@ -302,7 +306,7 @@ metadata:
|
|
302
306
|
documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
|
303
307
|
source_code_uri: https://gitlab.com/tools4devops/power_stencil
|
304
308
|
homepage_uri: https://powerstencil.brizone.org/
|
305
|
-
post_install_message: "\nThank you for installing PowerStencil 0.8.
|
309
|
+
post_install_message: "\nThank you for installing PowerStencil 0.8.14 !\nFrom the
|
306
310
|
command line you can run `power_stencil --help`\nIf your shell is not completing
|
307
311
|
the command:\n If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial
|
308
312
|
Website : https://powerstencil.brizone.org/\nFull documentation here :
|