power_stencil 0.8.11 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -15
- data/doc/faq.md +4 -7
- data/doc/git_integration.md +38 -12
- data/etc/meta_templates/plugin_seed/README.md +133 -0
- data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +20 -5
- data/etc/meta_templates/plugin_seed/spec/project_helper.rb +50 -0
- data/etc/meta_templates/plugin_seed/spec/spec_helper.rb +16 -0
- data/etc/meta_templates/plugin_seed/spec/{entity}_spec.rb +30 -0
- data/etc/power_stencil.yaml +6 -1
- data/etc/templates/plugin_definition/README.md +110 -20
- data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +20 -5
- data/etc/templates/plugin_definition/spec/project_helper.rb +50 -0
- data/etc/templates/plugin_definition/spec/spec_helper.rb +4 -2
- data/etc/templates/plugin_definition/spec/{entity}_spec.rb +24 -3
- 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/command_processors/create.rb +1 -1
- data/lib/power_stencil/dsl/completion.rb +37 -0
- data/lib/power_stencil/dsl/plugin_generation.rb +4 -0
- data/lib/power_stencil/engine/base.rb +2 -0
- data/lib/power_stencil/engine/build_handling.rb +5 -0
- data/lib/power_stencil/engine/directory_processor.rb +20 -1
- data/lib/power_stencil/engine/entities_handling.rb +2 -2
- data/lib/power_stencil/engine/renderers/haml.rb +21 -0
- data/lib/power_stencil/initializer.rb +6 -1
- data/lib/power_stencil/plugins/command_line.rb +3 -1
- data/lib/power_stencil/project/completion.rb +3 -5
- 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 +2 -1
- metadata +34 -11
data/etc/power_stencil.yaml
CHANGED
@@ -72,7 +72,9 @@
|
|
72
72
|
# Map to define which kind of template engine for which type of file. Be careful if you
|
73
73
|
# overlap two definitions. Warning, it is ruby Regex not shell pattern !
|
74
74
|
:templating_engines_map:
|
75
|
-
#
|
75
|
+
# Haml for .haml files
|
76
|
+
:haml: '\.haml$'
|
77
|
+
# All the rest with ERB
|
76
78
|
:erb: '.*'
|
77
79
|
|
78
80
|
# Files matching particular patterns can be changed on the fly
|
@@ -82,6 +84,8 @@
|
|
82
84
|
^(.+)\.zzzgitignore\.erb$: '\1.gitignore'
|
83
85
|
# Erb files
|
84
86
|
^(.+)\.erb$: '\1'
|
87
|
+
# Haml files
|
88
|
+
^(.+)\.haml$: '\1'
|
85
89
|
|
86
90
|
|
87
91
|
# PLUGINS
|
@@ -110,6 +114,7 @@
|
|
110
114
|
:completion_target:
|
111
115
|
:zsh:
|
112
116
|
:completion_dir: ~/.zsh/completion
|
117
|
+
:project_completion_filename: .zsh_project_completion
|
113
118
|
|
114
119
|
|
115
120
|
|
@@ -1,43 +1,133 @@
|
|
1
|
-
#
|
1
|
+
<% gem_name = "psplugin_#{ plugin_name}" -%>
|
2
|
+
<%= plugin_title_name %>
|
3
|
+
<%= '=' * plugin_title_name.size %>
|
2
4
|
|
3
|
-
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/<%= gem_name %>.svg)](https://rubygems.org/gems/<%= gem_name %>) [![Pipeline status](https://gitlab.com/tools4devops/psplugins/<%= gem_name %>/badges/master/pipeline.svg)](https://gitlab.com/tools4devops/psplugins/<%= gem_name %>/commits/master)
|
4
6
|
|
5
|
-
|
7
|
+
[PowerStencil] is the Swiss-army knife templating workflow for developers and ops.
|
6
8
|
|
7
|
-
|
9
|
+
`<%= plugin_title_name %>` is a [PowerStencil] plugin.
|
8
10
|
|
9
|
-
|
11
|
+
See [official website][PowerStencil site].
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
|
14
|
+
<!-- TOC -->
|
15
|
+
|
16
|
+
- [What is a PowerStencil plugin ?](#what-is-a-powerstencil-plugin-)
|
17
|
+
- [Using this plugin in your `PowerStencil` projects](#using-this-plugin-in-your-powerstencil-projects)
|
18
|
+
- [Goal of this plugin](#goal-of-this-plugin)
|
19
|
+
- [Plugin dependencies](#plugin-dependencies)
|
20
|
+
- [Standard gems dependencies](#standard-gems-dependencies)
|
21
|
+
- [Dependency to other plugins](#dependency-to-other-plugins)
|
22
|
+
- [Plugin capabilities](#plugin-capabilities)
|
23
|
+
- [Config](#config)
|
24
|
+
- [Subcommands and options](#subcommands-and-options)
|
25
|
+
- [Post-build actions](#post-build-actions)
|
26
|
+
- [DSL in templates and in `power_stencil shell`](#dsl-in-templates-and-in-power_stencil-shell)
|
27
|
+
- [Entity types](#entity-types)
|
28
|
+
- [Templates-templates](#templates-templates)
|
29
|
+
- [Contributing](#contributing)
|
30
|
+
- [License](#license)
|
31
|
+
- [Code of Conduct](#code-of-conduct)
|
32
|
+
|
33
|
+
<!-- /TOC -->
|
34
|
+
|
35
|
+
# What is a PowerStencil plugin ?
|
36
|
+
|
37
|
+
A `PowerStencil` plugin can be used in the context of a `PowerStencil` project and bring extra features to a standard project.
|
38
|
+
|
39
|
+
If you don't know what `PowerStencil` is made for, you may read [the documentation][PowerStencil] first.
|
40
|
+
|
41
|
+
Features provided by a plugin can be:
|
42
|
+
|
43
|
+
* Extra config.
|
44
|
+
* Extra subcommands or options added to the `power_stencil` command-line.
|
45
|
+
* Extra post-build actions.
|
46
|
+
* Extra DSL methods available in templates and in `power_stencil shell`.
|
47
|
+
* Extra entity types.
|
48
|
+
* Extra templates-templates.
|
49
|
+
|
50
|
+
# Using this plugin in your `PowerStencil` projects
|
51
|
+
|
52
|
+
To use this plugin within your `PowerStencil` project, you need to:
|
53
|
+
|
54
|
+
* be within a `PowerStencil` project :wink:.
|
55
|
+
* declare this plugin in the project configuration (from the root of your project in the `.ps_project/versioned-config.yaml` file).
|
56
|
+
|
57
|
+
In this yaml configuration file, you just have to add a new entry in the `:project_plugins` array or simply create it if it is not yet existing:
|
58
|
+
|
59
|
+
```yaml
|
60
|
+
:project_plugins:
|
61
|
+
- <%= gem_name %>
|
13
62
|
```
|
63
|
+
If this plugin is not already present on your machine, you may have to download it:
|
64
|
+
|
65
|
+
$ power_stencil plugin --install
|
14
66
|
|
15
|
-
And then
|
67
|
+
And then you may see information about the plugin by running:
|
16
68
|
|
17
|
-
|
69
|
+
* `power_stencil info` in the plugins section.
|
70
|
+
* `power_stencil plugin --list -v`
|
18
71
|
|
19
|
-
|
72
|
+
# Goal of this plugin
|
20
73
|
|
21
|
-
|
74
|
+
# Plugin dependencies
|
22
75
|
|
23
|
-
##
|
76
|
+
## Standard gems dependencies
|
24
77
|
|
25
|
-
|
78
|
+
Standard dependencies are declared normally in the _gemspec file_. They are automatically installed when installing the plugin with `power_stencil plugin --install`.
|
26
79
|
|
27
|
-
##
|
80
|
+
## Dependency to other plugins
|
28
81
|
|
29
|
-
|
82
|
+
For development purpose, dependency to other plugins are declared in the _gemspec file_ as _development dependency_.
|
30
83
|
|
31
|
-
|
84
|
+
But within a project, dependencies have to be added to the `:project_plugins` array in the project configuration file (`.ps_project/versioned-config.yaml`).
|
32
85
|
|
33
|
-
## Contributing
|
34
86
|
|
35
|
-
|
87
|
+
# Plugin capabilities
|
88
|
+
|
89
|
+
This plugin provides the following features:
|
90
|
+
|
91
|
+
## Config
|
92
|
+
|
93
|
+
## Subcommands and options
|
94
|
+
|
95
|
+
## Post-build actions
|
96
|
+
|
97
|
+
## DSL in templates and in `power_stencil shell`
|
98
|
+
|
99
|
+
## Entity types
|
100
|
+
|
101
|
+
## Templates-templates
|
102
|
+
|
103
|
+
# Contributing
|
104
|
+
|
105
|
+
Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/tools4devops/psplugins/<%= plugin_name %>/issues. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
106
|
|
37
107
|
## License
|
38
108
|
|
39
|
-
The gem is available as open source under the terms of the [MIT License]
|
109
|
+
The gem is available as open source under the terms of the [MIT License].
|
40
110
|
|
41
111
|
## Code of Conduct
|
42
112
|
|
43
|
-
Everyone interacting in the
|
113
|
+
Everyone interacting in the PowerStencil project’s codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct].
|
114
|
+
|
115
|
+
<!-- End of Document -->
|
116
|
+
|
117
|
+
<!-- Pages -->
|
118
|
+
[code of conduct]: CODE_OF_CONDUCT.md
|
119
|
+
|
120
|
+
<!-- Code links -->
|
121
|
+
|
122
|
+
<!-- Illustrations -->
|
123
|
+
[simple-flow-image]: doc/images/power-stencil-simple-flow.svg
|
124
|
+
|
125
|
+
<!-- External links -->
|
126
|
+
[MIT License]: http://opensource.org/licenses/MIT "The MIT license"
|
127
|
+
[ERB]: https://ruby-doc.org/stdlib-2.6.3/libdoc/erb/rdoc/ERB.html "Quick ERB description"
|
128
|
+
[Haml]: http://haml.info/ "The templating engine for XML-like documents"
|
129
|
+
[Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
|
130
|
+
[Rails]: https://rubyonrails.org/ "The Ruby on Rails framework"
|
131
|
+
[PowerStencil site]: https://powerstencil.brizone.org "Official PowerStencil website"
|
132
|
+
[PowerStencil]: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md "PowerStencil documentation"
|
133
|
+
[PowerStencil plugins]: https://gitlab.com/tools4devops/power_stencil/blob/master/doc/plugins.md "PowerStencil plugins documentation"
|
@@ -12,13 +12,27 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{<%= plugin_name %> is a plugin for the PowerStencil framework.}
|
13
13
|
spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
14
|
spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
-
spec.license =
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# Change this and following metadata if you don't want your plugin to be an "official" PowerStencil plugin.
|
18
|
+
# ie deployed to https://gitlab.com/tools4devops/psplugins
|
19
|
+
source_code_uri = 'https://gitlab.com/tools4devops/psplugins/<%= plugin_name %>'
|
20
|
+
|
21
|
+
# Gem metadata
|
19
22
|
if spec.respond_to?(:metadata)
|
23
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
24
|
+
# to allow pushing to a single host or delete this line to allow pushing to any host.
|
20
25
|
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
|
26
|
+
|
27
|
+
# Nice link to your home page on rubygems.org
|
28
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
29
|
+
|
30
|
+
# You have to probably change this if you don't deploy to gitlab
|
31
|
+
spec.metadata['bug_tracker_uri'] = "#{source_code_uri}/issues"
|
32
|
+
spec.metadata['documentation_uri'] = "#{source_code_uri}/blob/master/README.md"
|
33
|
+
spec.metadata['source_code_uri'] = source_code_uri
|
34
|
+
|
35
|
+
# This metadata is mandatory for a PowerStencil plugin !!
|
22
36
|
spec.metadata['plugin_name'] = '<%= plugin_name %>'
|
23
37
|
else
|
24
38
|
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes and PowerStencil plugin mechanism !'
|
@@ -31,8 +45,9 @@ Gem::Specification.new do |spec|
|
|
31
45
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
46
|
spec.require_paths = ['lib']
|
33
47
|
|
34
|
-
spec.add_development_dependency 'bundler'
|
48
|
+
spec.add_development_dependency 'bundler'
|
35
49
|
spec.add_development_dependency 'rake', '~> 10.0'
|
36
50
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
51
|
spec.add_development_dependency 'power_stencil', "~> <%= PowerStencil::VERSION %>"
|
52
|
+
|
38
53
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module PowerStencilTests
|
2
|
+
|
3
|
+
module Project
|
4
|
+
|
5
|
+
TEMP_DIR_PREFIX = 'PS_TESTS_'
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
|
10
|
+
def temporary_project(project_name, with_git_support: false, scope: :all)
|
11
|
+
self.instance_eval do
|
12
|
+
puts scope
|
13
|
+
around(scope) do |execution|
|
14
|
+
Dir.mktmpdir(TEMP_DIR_PREFIX) do |tests_root_dir|
|
15
|
+
tmp_project_path = File.join tests_root_dir, project_name
|
16
|
+
create_project_including_this_plugin tmp_project_path, with_git_support: with_git_support
|
17
|
+
execution.run
|
18
|
+
@tmp_project_path = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def plugin_path
|
25
|
+
File.expand_path File.join('..', '..'), __FILE__
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_reader :tmp_project_path
|
31
|
+
|
32
|
+
def self.included(base)
|
33
|
+
base.extend(ClassMethods)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_project_including_this_plugin(project_path, with_git_support: false)
|
37
|
+
cmd = "power_stencil init --project-path '#{project_path}'"
|
38
|
+
cmd << ' --no-git' unless with_git_support
|
39
|
+
`#{cmd}`
|
40
|
+
project_plugin_path = File.join project_path, '.ps_project', 'plugins'
|
41
|
+
`ln -s '#{self.class.plugin_path}' '#{project_plugin_path}'`
|
42
|
+
@tmp_project_path = project_path
|
43
|
+
end
|
44
|
+
|
45
|
+
def temporary_project_cmd(params)
|
46
|
+
"power_stencil #{params} --project-path '#{tmp_project_path}'"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -1,9 +1,30 @@
|
|
1
1
|
RSpec.describe <%= plugin_module_name %> do
|
2
|
-
|
2
|
+
|
3
|
+
include PowerStencilTests::Project
|
4
|
+
temporary_project 'test_project', scope: :all
|
5
|
+
|
6
|
+
let(:plugin_list) { 'plugin --list' }
|
7
|
+
let(:test_entity) { '<%= plugin_name %>_entity/test_<%= plugin_name %>' }
|
8
|
+
let(:create_<%= plugin_name %>) { "create #{test_entity}" }
|
9
|
+
let(:get_<%= plugin_name %>) { "get #{test_entity}" }
|
10
|
+
|
11
|
+
it 'has a version number' do
|
3
12
|
expect(<%= plugin_module_name %>::VERSION).not_to be nil
|
4
13
|
end
|
5
14
|
|
6
|
-
it "
|
7
|
-
expect(
|
15
|
+
it 'should add a "<%= plugin_name %>" sub-command' do
|
16
|
+
expect(`#{temporary_project_cmd plugin_list}`).to match '- <%= plugin_name %>'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should be possible to create a "<%= plugin_name %>_entity"' do
|
20
|
+
`#{temporary_project_cmd create_<%= plugin_name %>}`
|
21
|
+
expect($?.success?).to be_truthy
|
22
|
+
expect(`#{temporary_project_cmd get_<%= plugin_name %>}`).not_to be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should do something useful' do
|
26
|
+
pending 'Tests implementation'
|
27
|
+
RSpec.fail
|
8
28
|
end
|
29
|
+
|
9
30
|
end
|
@@ -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
|
|
@@ -41,8 +41,8 @@ module PowerStencil
|
|
41
41
|
end
|
42
42
|
puts_and_logs "Generated templates in '#{new_entity.templates_path}'.", check_verbose: false if new_entity.buildable?
|
43
43
|
rescue => e
|
44
|
-
puts_and_logs "Failed to create '#{search_criterion.as_path}' with message '#{e.message}'.", logs_as: :error, check_verbose: false
|
45
44
|
logger.debug PowerStencil::Error.report_error(e)
|
45
|
+
raise PowerStencil::Error, "Failed to create '#{search_criterion.as_path}' with message '#{e.message}'."
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -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
|