sutty-cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +168 -0
  3. data/README.md +60 -0
  4. data/exe/sutty-cli +18 -0
  5. data/lib/sutty/cli.rb +8 -0
  6. data/lib/sutty/cli/cli.rb +163 -0
  7. data/lib/sutty/cli/command.rb +123 -0
  8. data/lib/sutty/cli/commands/container.rb +39 -0
  9. data/lib/sutty/cli/commands/field.rb +87 -0
  10. data/lib/sutty/cli/commands/layout.rb +57 -0
  11. data/lib/sutty/cli/commands/post.rb +69 -0
  12. data/lib/sutty/cli/commands/theme.rb +49 -0
  13. data/lib/sutty/cli/templates/field/array.yml.erb +14 -0
  14. data/lib/sutty/cli/templates/field/belongs_to.yml.erb +16 -0
  15. data/lib/sutty/cli/templates/field/boolean.yml.erb +11 -0
  16. data/lib/sutty/cli/templates/field/color.yml.erb +11 -0
  17. data/lib/sutty/cli/templates/field/content.yml.erb +14 -0
  18. data/lib/sutty/cli/templates/field/date.yml.erb +11 -0
  19. data/lib/sutty/cli/templates/field/email.yml.erb +14 -0
  20. data/lib/sutty/cli/templates/field/encrypted_text.yml.erb +11 -0
  21. data/lib/sutty/cli/templates/field/event.yml.erb +40 -0
  22. data/lib/sutty/cli/templates/field/file.yml.erb +19 -0
  23. data/lib/sutty/cli/templates/field/geo.yml.erb +17 -0
  24. data/lib/sutty/cli/templates/field/has_and_belongs_to_many.yml.erb +16 -0
  25. data/lib/sutty/cli/templates/field/has_many.yml.erb +16 -0
  26. data/lib/sutty/cli/templates/field/image.yml.erb +19 -0
  27. data/lib/sutty/cli/templates/field/locales.yml.erb +11 -0
  28. data/lib/sutty/cli/templates/field/markdown.yml.erb +14 -0
  29. data/lib/sutty/cli/templates/field/markdown_content.yml.erb +14 -0
  30. data/lib/sutty/cli/templates/field/number.yml.erb +11 -0
  31. data/lib/sutty/cli/templates/field/order.yml.erb +11 -0
  32. data/lib/sutty/cli/templates/field/predefined_array.yml.erb +18 -0
  33. data/lib/sutty/cli/templates/field/related_posts.yml.erb +15 -0
  34. data/lib/sutty/cli/templates/field/string.yml.erb +14 -0
  35. data/lib/sutty/cli/templates/field/tel.yml.erb +14 -0
  36. data/lib/sutty/cli/templates/field/text.yml.erb +14 -0
  37. data/lib/sutty/cli/templates/field/url.yml.erb +14 -0
  38. data/lib/sutty/cli/version.rb +5 -0
  39. metadata +179 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 726ea044b998ea763c8c941c3d047c8ad4e5f9408c4fe793a459e24c9b33304d
4
+ data.tar.gz: 198cfd1156845cd785aaf2eeb205a68965bda05c92f06f9f7f754f9240a31ea4
5
+ SHA512:
6
+ metadata.gz: 37554d14cbe7ec4f8f971d71b49a61860ee0b997b5bd67ac61cd6c062eb5920bd69f1e38b6f571963d843d39b66f7743b0ab727bd591a102fea553e742f50576
7
+ data.tar.gz: c0a4dc6b224cd4e5c5c0ab2675966fddd97ecdccf89a62ee040bdd124d02d59892e0496437b8800702f96304c02c9d21afd0eea01d513c5a37cb8c4672f1e559
@@ -0,0 +1,168 @@
1
+ Copyright (c) 2019 Sutty
2
+
3
+ The following license is modified from the MIT license and downloaded
4
+ from <https://github.com/Laurelai/anti-fascist-mit-license> on
5
+ 2019-07-11.
6
+
7
+ Anti-Fascist MIT License:
8
+
9
+ The following conditions must be met by any person obtaining a copy of
10
+ this software:
11
+
12
+ - You MAY NOT be a fascist.
13
+ - You MUST not financially support fascists.
14
+ - You MUST not intentionally provide or knowingly provide through
15
+ inaction a platform for fascists to spread propaganda or organize.
16
+ - You MUST not publicly voice support for fascists.
17
+ - You MAY NOT be a member of any fascist organization, even if you are a
18
+ member to infiltrate for anti-fascist purposes.
19
+
20
+ "Fascist" can be understood as any group or individual who promotes the
21
+ political ideology of fascism.
22
+
23
+ "Fascism" can be broken down into 11 ideological features as well as 8
24
+ tactics that can form a fascist system in varying combinations, for the
25
+ sake of simplicity and brevity the individual or organization in
26
+ question must match to at least 5 features or tactics or a combination
27
+ of the two determined by the individual licencer.
28
+
29
+ Said licencer may provide a list if an individual or group matches to at
30
+ least 5 features upon request from the individual or group in question.
31
+
32
+ The ideological features are listed below.
33
+
34
+ 1. Hyper-nationalism.
35
+
36
+ As defined as "The belief in the superiority of one's nation and of the
37
+ paramount importance of advancing it."
38
+
39
+ 2. Militarism.
40
+
41
+ As defined as "Advocating for an increase in military forces beyond what
42
+ the real defense of a nation needs, more influence of the military upon
43
+ the policies of the civilian government, and a preference for force as a
44
+ solution over diplomacy for problems."
45
+
46
+ 3. Glorification of violence and readiness to use it in politics.
47
+
48
+ As defined as "The belief that violence can be used to cleanse a
49
+ tarnished nation, also by using violence to harm, intimidate or kill
50
+ political oppoenents."
51
+
52
+ 4. Fetishization of youth.
53
+
54
+ As defined as "Extolling the virtues of youth and making a special
55
+ appeal to young people to join a cause or organization"
56
+
57
+ 5. Fetishization of masculinity.
58
+
59
+ As defined as "Extolling the virtues of male authority or patriarchy and
60
+ making a special appeal to men to be leaders of households and groups"
61
+
62
+ 6. Leader cult.
63
+
64
+ As defined as "Creating an idealized, heroic, and worshipful image of a
65
+ leader, often through unquestioning flattery and praise."
66
+
67
+ 7. Lost-golden-age syndrome.
68
+
69
+ As defined as "Creating or promoting the idea that a nation had a lost
70
+ or stolen golden age in the past that must be returned to"
71
+
72
+ 8. Self-definition by opposition.
73
+
74
+ As defined as "Creating or promoting the idea that the group or
75
+ individual is the only person or way who can fight real or imagined
76
+ evils within a society."
77
+
78
+ 9. Mass mobilization and mass party.
79
+
80
+ As defined as "Creating or promoting the creation of a populist group or
81
+ party for the advancment of fascist tactics or features."
82
+
83
+ 10. Hierarchical party structure and tendency to purge the disloyal.
84
+
85
+ As defined as "Removal of membership from a group for lacking absolute
86
+ loyalty or lacking further usefulness to the group. Also having a
87
+ hierarchical structure within the group itself."
88
+
89
+ 11. Theatricality.
90
+
91
+ As defined as "Using spectacle to gain and keep the attention of those
92
+ inside and outside of the group using speeches full of absolutes and or
93
+ superlatives. Elaborate collective rituals (rallies) meant to reenforce
94
+ loyalty within the group."
95
+
96
+ Fascist tactics include
97
+
98
+ 1) Persecution of national minorities.
99
+ 2) Persecution of racial minorities.
100
+ 3) Persecution of religious minorities (Anti-Semitism, Islamophobia and others).
101
+ 4) Promotion of a type of national purity.
102
+ 5) Promotion of a state run by ideologically oriented corporate bodies.
103
+ 6) Persecution of gender or sexual minorities.
104
+ 7) Persecution of the disabled.
105
+ 8) Formation of extra-legal forces (brownshirts) to defend fascist values.
106
+
107
+ Special criteria: Meeting only one point of the special criteria is
108
+ enough to consider someone or a group to be fascist for the purposes of
109
+ this licence.
110
+
111
+ 1. Promotion of any theories that state members of the jewish ethnicity
112
+ or faith control or largely control the world, finance, or other
113
+ global major power system.
114
+
115
+ 2. Denial of the holocaust or any other historically proven genocide.
116
+
117
+ 3. Promotion of ethnostates.
118
+
119
+ 4. Advocating for eugenics. Either positive or negative eugenics.
120
+ Promotion for the rights of abortion are not considered eugenics.
121
+
122
+ 5. Advocating for the removal of rights or legal protections from a
123
+ class or group of people.
124
+
125
+ Former fascists: People or organizations who used to promote the
126
+ political ideology of fascism but no longer do so must meet the
127
+ following criterea to be able to use this software.
128
+
129
+ 1. Publicly disavow past fascist deeds and ideologies.
130
+
131
+ 2. Expose any and all known fascists former allies to the public.
132
+
133
+ A suggested route would be through the one peoples project
134
+ (onepeoplesproject.com). If they can confirm you have done so that
135
+ will count as meeting condition two.
136
+
137
+ 3. Publicly destroy any and all fascist paraphenelia you have in your
138
+ posession including removal of tattoos and body markings
139
+ affiliated with fascist groups or gangs.
140
+
141
+ ANTI-FASCIST-MIT LICENSE:
142
+
143
+ Permission is hereby granted, free of charge, to any person obtaining a
144
+ copy of this software and associated documentation files (the
145
+ "Software"), to deal in the Software without restriction, including
146
+ without limitation the rights to use, copy, modify, merge, publish,
147
+ distribute, sublicense, and/or sell copies of the Software, and to
148
+ permit persons to whom the Software is furnished to do so, subject to
149
+ the following conditions:
150
+
151
+ The above copyright notice and this permission notice shall be included
152
+ in all copies or substantial portions of the Software.
153
+
154
+ The above licence agreement conditions are met in full.
155
+
156
+ The Anti-Fascist MIT License may only be used under the terms of the
157
+ Anti-Fascist MIT License.
158
+
159
+ Any modified versions of this software must also include the
160
+ Anti-Fascist MIT Licence.
161
+
162
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
163
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
164
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
165
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
166
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
167
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
168
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,60 @@
1
+ # Sutty CLI
2
+
3
+ Tools to ease Sutty's themes and plugins development.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sutty-cli'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sutty-cli
20
+
21
+ ## Usage
22
+
23
+ ```bash
24
+ sutty-cli help
25
+ ```
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install
30
+ dependencies. Then, run `rake spec` to run the tests. You can also run
31
+ `bin/console` for an interactive prompt that will allow you to
32
+ experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake
35
+ install`. To release a new version, update the version number in
36
+ `version.rb`, and then run `bundle exec rake release`, which will create
37
+ a git tag for the version, push git commits and tags, and push the
38
+ `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on 0xacab at
43
+ https://0xacab.org/sutty/sutty-cli. This project is intended to be
44
+ a safe, welcoming space for collaboration, and contributors are expected
45
+ to adhere to the [Sutty code of
46
+ conduct](https://sutty.nl/en/code-of-conduct/).
47
+
48
+ If you like our work, [please consider
49
+ donating](https://donaciones.sutty.nl/en/)!
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the sutty-cli project’s codebases,
54
+ issue trackers, chat rooms and mailing lists is expected to follow the
55
+ [code of conduct](https://sutty.nl/en/code-of-conduct/).
56
+
57
+ ## Copyright
58
+
59
+ The gem is available as free software under the terms of the MIT Antifa
60
+ License.
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'sutty/cli/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Sutty::Cli::CLI.start
15
+ rescue Sutty::Cli::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
@@ -0,0 +1,8 @@
1
+ require "sutty/cli/version"
2
+
3
+ module Sutty
4
+ module Cli
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,163 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'date'
5
+ require_relative 'commands/layout'
6
+ require_relative 'commands/field'
7
+
8
+ module Sutty
9
+ module Cli
10
+ # Handle the application command line parsing
11
+ # and the dispatch to various command objects
12
+ #
13
+ # @api public
14
+ class CLI < Thor
15
+ # Error raised by this runner
16
+ Error = Class.new(StandardError)
17
+
18
+ desc 'version', 'sutty-cli version'
19
+ def version
20
+ require_relative 'version'
21
+ puts "v#{Sutty::Cli::VERSION}"
22
+ end
23
+ map %w(--version -v) => :version
24
+
25
+ desc 'post NAME', 'Adds a post'
26
+ method_option :help, aliases: '-h', type: :boolean,
27
+ desc: 'Display usage information'
28
+
29
+ method_option :layout,
30
+ aliases: '-l',
31
+ type: :string,
32
+ desc: 'Layout',
33
+ required: true,
34
+ enum: Sutty::Cli::Commands::Layout.layouts
35
+
36
+ method_option :title,
37
+ aliases: '-t',
38
+ type: :string,
39
+ desc: 'Title',
40
+ required: true
41
+
42
+ method_option :date,
43
+ aliases: '-d',
44
+ type: :string,
45
+ desc: 'Date',
46
+ default: Date.today.to_s
47
+
48
+ # TODO: Bring locales from Jekyll configuration
49
+ method_option :locale,
50
+ aliases: '-L',
51
+ type: :string,
52
+ desc: 'Locale collection',
53
+ default: 'posts'
54
+
55
+ def post
56
+ if options[:help]
57
+ invoke :help, ['post']
58
+ else
59
+ require_relative 'commands/post'
60
+ Sutty::Cli::Commands::Post.new(options).execute
61
+ end
62
+ end
63
+
64
+ desc 'container NAME', 'Adds a container'
65
+ method_option :help, aliases: '-h', type: :boolean,
66
+ desc: 'Display usage information'
67
+ def container(name)
68
+ if options[:help]
69
+ invoke :help, ['container']
70
+ else
71
+ require_relative 'commands/container'
72
+ Sutty::Cli::Commands::Container.new(name, options).execute
73
+ end
74
+ end
75
+
76
+ desc 'field NAME', 'Adds a field with a type to a layout'
77
+ long_desc <<~EOD
78
+ A field is a data type with a name, from which Sutty can build a
79
+ form on the panel and use it to validate posts.
80
+
81
+ After you add a field, edit the layout file and add labels and
82
+ help description in different languages.
83
+ EOD
84
+
85
+ method_option :help,
86
+ aliases: '-h',
87
+ type: :boolean,
88
+ desc: 'Display usage information'
89
+
90
+ method_option :layout,
91
+ aliases: '-l',
92
+ type: :string,
93
+ desc: 'Layout to add',
94
+ required: true,
95
+ enum: Sutty::Cli::Commands::Layout.layouts
96
+
97
+ method_option :type,
98
+ aliases: '-t',
99
+ type: :string,
100
+ desc: 'Field type',
101
+ required: true,
102
+ enum: Sutty::Cli::Commands::Field.fields
103
+
104
+ method_option :required,
105
+ aliases: '-r',
106
+ type: :boolean,
107
+ desc: 'Field is required'
108
+
109
+ method_option :private,
110
+ aliases: '-p',
111
+ type: :boolean,
112
+ desc: 'Field is private (encrypted)'
113
+
114
+ method_option :inverse,
115
+ aliases: '-i',
116
+ type: :string,
117
+ desc: 'Inverse relation',
118
+ required: Sutty::Cli::Commands::Field.inverse_required?
119
+
120
+ method_option :filter,
121
+ aliases: '-F',
122
+ type: :string,
123
+ desc: 'Filter relations by this field'
124
+
125
+ method_option :value,
126
+ aliases: '-v',
127
+ type: :string,
128
+ desc: 'Filter relations by this field value',
129
+ required: Sutty::Cli::Commands::Field.value_required?
130
+
131
+ def field(name)
132
+ if options[:help]
133
+ invoke :help, ['field']
134
+ else
135
+ Sutty::Cli::Commands::Field.new(name, options).execute
136
+ end
137
+ end
138
+
139
+ desc 'layout NAME', 'Start a new layout'
140
+ method_option :help, aliases: '-h', type: :boolean,
141
+ desc: 'Display usage information'
142
+ def layout(name)
143
+ if options[:help]
144
+ invoke :help, ['layout']
145
+ else
146
+ Sutty::Cli::Commands::Layout.new(name, options).execute
147
+ end
148
+ end
149
+
150
+ desc 'theme NAME', 'Start a new theme'
151
+ method_option :help, aliases: '-h', type: :boolean,
152
+ desc: 'Display usage information'
153
+ def theme(name)
154
+ if options[:help]
155
+ invoke :help, ['theme']
156
+ else
157
+ require_relative 'commands/theme'
158
+ Sutty::Cli::Commands::Theme.new(name, options).execute
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Sutty
6
+ module Cli
7
+ class Command
8
+ extend Forwardable
9
+
10
+ def_delegators :command, :run
11
+
12
+ # Execute this command
13
+ #
14
+ # @api public
15
+ def execute(*)
16
+ raise(
17
+ NotImplementedError,
18
+ "#{self.class}##{__method__} must be implemented"
19
+ )
20
+ end
21
+
22
+ # The external commands runner
23
+ #
24
+ # @see http://www.rubydoc.info/gems/tty-command
25
+ #
26
+ # @api public
27
+ def command(**options)
28
+ require 'tty-command'
29
+ TTY::Command.new(options)
30
+ end
31
+
32
+ # The cursor movement
33
+ #
34
+ # @see http://www.rubydoc.info/gems/tty-cursor
35
+ #
36
+ # @api public
37
+ def cursor
38
+ require 'tty-cursor'
39
+ TTY::Cursor
40
+ end
41
+
42
+ # Open a file or text in the user's preferred editor
43
+ #
44
+ # @see http://www.rubydoc.info/gems/tty-editor
45
+ #
46
+ # @api public
47
+ def editor
48
+ require 'tty-editor'
49
+ TTY::Editor
50
+ end
51
+
52
+ # File manipulation utility methods
53
+ #
54
+ # @see http://www.rubydoc.info/gems/tty-file
55
+ #
56
+ # @api public
57
+ def generator
58
+ require 'tty-file'
59
+ TTY::File
60
+ end
61
+
62
+ # Terminal output paging
63
+ #
64
+ # @see http://www.rubydoc.info/gems/tty-pager
65
+ #
66
+ # @api public
67
+ def pager(**options)
68
+ require 'tty-pager'
69
+ TTY::Pager.new(options)
70
+ end
71
+
72
+ # Terminal platform and OS properties
73
+ #
74
+ # @see http://www.rubydoc.info/gems/tty-pager
75
+ #
76
+ # @api public
77
+ def platform
78
+ require 'tty-platform'
79
+ TTY::Platform.new
80
+ end
81
+
82
+ # The interactive prompt
83
+ #
84
+ # @see http://www.rubydoc.info/gems/tty-prompt
85
+ #
86
+ # @api public
87
+ def prompt(**options)
88
+ require 'tty-prompt'
89
+ TTY::Prompt.new(options)
90
+ end
91
+
92
+ # Get terminal screen properties
93
+ #
94
+ # @see http://www.rubydoc.info/gems/tty-screen
95
+ #
96
+ # @api public
97
+ def screen
98
+ require 'tty-screen'
99
+ TTY::Screen
100
+ end
101
+
102
+ # The unix which utility
103
+ #
104
+ # @see http://www.rubydoc.info/gems/tty-which
105
+ #
106
+ # @api public
107
+ def which(*args)
108
+ require 'tty-which'
109
+ TTY::Which.which(*args)
110
+ end
111
+
112
+ # Check if executable exists
113
+ #
114
+ # @see http://www.rubydoc.info/gems/tty-which
115
+ #
116
+ # @api public
117
+ def exec_exist?(*args)
118
+ require 'tty-which'
119
+ TTY::Which.exist?(*args)
120
+ end
121
+ end
122
+ end
123
+ end