sublime_text_kit 10.0.0 → 11.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -1
  3. data/README.adoc +49 -70
  4. data/bin/sublime_text_kit +1 -3
  5. data/lib/sublime_text_kit/cli/actions/config.rb +35 -0
  6. data/lib/sublime_text_kit/cli/actions/metadata.rb +63 -0
  7. data/lib/sublime_text_kit/cli/actions/session.rb +26 -0
  8. data/lib/sublime_text_kit/cli/actions/snippets.rb +37 -0
  9. data/lib/sublime_text_kit/cli/actions/update.rb +42 -0
  10. data/lib/sublime_text_kit/cli/configuration/content.rb +45 -0
  11. data/lib/sublime_text_kit/cli/configuration/defaults.yml +3 -0
  12. data/lib/sublime_text_kit/cli/configuration/loader.rb +37 -0
  13. data/lib/sublime_text_kit/cli/parsers/assembler.rb +32 -0
  14. data/lib/sublime_text_kit/cli/parsers/core.rb +100 -0
  15. data/lib/sublime_text_kit/cli/parsers.rb +11 -0
  16. data/lib/sublime_text_kit/cli/shell.rb +58 -0
  17. data/lib/sublime_text_kit/container.rb +37 -0
  18. data/lib/sublime_text_kit/identity.rb +3 -2
  19. data/lib/sublime_text_kit/metadata/handler.rb +43 -0
  20. data/lib/sublime_text_kit/metadata/pathway.rb +19 -0
  21. data/lib/sublime_text_kit/metadata/serializers/project.rb +24 -0
  22. data/lib/sublime_text_kit/metadata/serializers/workspace.rb +27 -0
  23. data/lib/sublime_text_kit/sessions/rebuilder.rb +44 -0
  24. data/lib/sublime_text_kit/snippets/collector.rb +13 -19
  25. data/lib/sublime_text_kit/snippets/model.rb +31 -0
  26. data/lib/sublime_text_kit/snippets/printers/ascii_doc.rb +7 -5
  27. data/lib/sublime_text_kit/snippets/printers/markdown.rb +7 -3
  28. data/lib/sublime_text_kit/snippets/reader.rb +21 -0
  29. data/lib/sublime_text_kit.rb +11 -10
  30. data.tar.gz.sig +0 -0
  31. metadata +66 -24
  32. metadata.gz.sig +0 -0
  33. data/lib/sublime_text_kit/cli.rb +0 -182
  34. data/lib/sublime_text_kit/metadata/base.rb +0 -60
  35. data/lib/sublime_text_kit/metadata/project_metadata.rb +0 -20
  36. data/lib/sublime_text_kit/metadata/workspace_metadata.rb +0 -23
  37. data/lib/sublime_text_kit/session.rb +0 -44
  38. data/lib/sublime_text_kit/snippets/snippet.rb +0 -56
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed697b0ab658bd9c3239461c5dd0c80ed3fec31fd51493b921fd959692b0a111
4
- data.tar.gz: 5c0f1bfbb42506f2cecb2f994309e4a30b5774f5267d7cf4c8ec172d1e4ce045
3
+ metadata.gz: f09a97c9c7bd65b2e03cbcd38b5d7eea709ee4a253e6be57ac3101d948f7a3df
4
+ data.tar.gz: 4eb97c05c9d833826fcab6ddb812fa33ca94a9b595d991066247250dcfc0682c
5
5
  SHA512:
6
- metadata.gz: 681e609cfbf9b1bc0bf5c15861e3154125e00a039bdd2911fd25870153d73cafa3f74453414364f071010d04d1d459bd8b2c3bbac78950a5cf32acd8d01f1372
7
- data.tar.gz: 84fe9958b5679d15995b5b92c0bd25efefd0b4b3a5423e3cc152339b0fa5376ea03fdc9708d9ef0ef245ce4887b80277cbe810ebc5df327000a0f92f606ca12c
6
+ metadata.gz: e7035860e908e521ec4445ceaa7bb8d3dcfa10974aa6885dba538c214e8a8c531550c596556c9e3d9d13bd181116c8ec2a4a4c9f075e5c8dea8125daccdf5289
7
+ data.tar.gz: '0385887b44d98e5742e5b8a1a277a518886d119700ba76b2d143349dfc4db8a7973ea94f7e76e23918e6c1c45ab0d920861fce3000645997d21a4382e0582729'
checksums.yaml.gz.sig CHANGED
@@ -1 +1,2 @@
1
- �\H篇�eގQ"��- ��l�ߗIf!����t{RR��XX ��ɸ魓������#�"ٛX5c�'���s��>١=`Zo�5��c��L��Y��g
1
+ nc�آs׽{m1pT�*N�� _PL�� :��+!:��v����v�!e�w٥o9��
2
+ ��w'�[�4���B�C��`�=[
data/README.adoc CHANGED
@@ -11,22 +11,20 @@ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchem
11
11
  [link=https://circleci.com/gh/bkuhlmann/sublime_text_kit]
12
12
  image::https://circleci.com/gh/bkuhlmann/sublime_text_kit.svg?style=svg[Circle CI Status]
13
13
 
14
- A command line interface for managing Sublime Text metadata.
14
+ Sublime Text Kit is a command line interface for managing Sublime Text metadata for multiple
15
+ projects, sessions, snippets, etc. This allows you to avoiding manual maintenance of your workspace
16
+ so you can stay focused on your own work.
15
17
 
16
18
  toc::[]
17
19
 
18
20
  == Features
19
21
 
20
- * Provides project metadata (i.e. `.sublime-project` and `.sublime-workspace` files) management for
21
- project switching via the `CONTROL+COMMAND+P` shortcut.
22
- * Rebuilds project history (Project -> Recent Projects) from existing project files (assumes project
23
- metadata is in a directory) so one can easily toggle between up-to-date project information via
24
- the `CONTROL+COMMAND+P` shortcut.
25
-
26
- == Screencasts
27
-
28
- [link=https://www.alchemists.io/screencasts/sublime_text_kit]
29
- image::https://www.alchemists.io/images/screencasts/sublime_text_kit/cover.svg[Screencast,600,240,role=focal_point]
22
+ * Manages project metadata (`.sublime-project` and `.sublime-workspace` files).
23
+ * Manages session metadata so you can quickly toggle between projects via the `CONTROL+COMMAND+p`
24
+ shortcut.
25
+ * Prints all of your custom snippets in either
26
+ link:https://daringfireball.net/projects/markdown[Markdown] or
27
+ link:https://asciidoctor.org[ASCII Doc] format.
30
28
 
31
29
  == Requirements
32
30
 
@@ -49,41 +47,14 @@ gem install sublime_text_kit
49
47
  From the command line, type: `sublime_text_kit`
50
48
 
51
49
  ....
52
- sublime_text_kit -c, [--config] # Manage gem configuration.
53
- sublime_text_kit -h, [--help=COMMAND] # Show this message or get help for a command.
54
- sublime_text_kit -m, [--metadata] # Manage project/workspace metadata.
55
- sublime_text_kit -p, [--snippets] # Print user defined snippets.
56
- sublime_text_kit -s, [--session] # Manage session metadata.
57
- sublime_text_kit -u, [--update] # Update Sublime Text with current settings.
58
- sublime_text_kit -v, [--version] # Show gem version.
59
- ....
60
-
61
- For configuration options, type: `sublime_text_kit --help --config`
62
-
63
- ....
64
- -e, [--edit], [--no-edit] # Edit gem configuration.
65
- -i, [--info], [--no-info] # Print gem configuration.
66
- ....
67
-
68
- For metadata options, type: `sublime_text_kit --help --metadata`
69
-
70
- ....
71
- -c, [--create], [--no-create] # Create metadata.
72
- -D, [--destroy], [--no-destroy] # Destroy metadata.
73
- -R, [--rebuild], [--no-rebuild] # Rebuild metadata.
74
- ....
75
-
76
- For session options, type: `sublime_text_kit --help --session`
77
-
78
- ....
79
- -R, [--rebuild], [--no-rebuild] # Rebuild session metadata.
80
- ....
81
-
82
- For snippet options, type: `sublime_text_kit --help --snippets`
83
-
84
- ....
85
- -a, [--ascii-doc], [--no-ascii-doc] # Print snippets in ASCII Doc format.
86
- -m, [--markdown], [--no-markdown] # Print snippets in Markdown format.
50
+ USAGE:
51
+ -c, --config ACTION Manage gem configuration. Actions: edit or view.
52
+ -h, --help Show this message.
53
+ -m, --metadata ACTION Manage project metadata. Actions: create, delete, or recreate.
54
+ -S, --session Rebuild session metadata.
55
+ -s, --snippets [FORMAT] View snippets. Default: ascii_doc. Formats: markdown or ascii_doc.
56
+ -u, --update Update project and session metadata based on current settings.
57
+ -v, --version Show gem version.
87
58
  ....
88
59
 
89
60
  === Customization
@@ -97,26 +68,26 @@ An example configuration could be:
97
68
  [source,yaml]
98
69
  ----
99
70
  :project_roots:
100
- - "~/Dropbox/Development/Misc"
101
- - "~/Dropbox/Development/OSS"
102
- - "~/Dropbox/Development/Work"
71
+ - "~/Engineering/Organizations"
72
+ - "~/Engineering/OSS"
103
73
  :metadata_dir: "~/Dropbox/Cache/Sublime"
74
+ :snippets_format: :ascii_doc
104
75
  ----
105
76
 
106
- Feel free to take this configuration, modify, and save as your own custom `+configuration.yml+`.
77
+ Feel free to take this configuration, modify, and save as your own.
107
78
 
108
- The project roots define the root level directories where project folders are located. When project
109
- metadata (i.e. `.sublime-project`, `.sublime-workspace`) is generated, the name of the metadata file
110
- will be the same name as that of the project folder. All project metadata, regardless of root
111
- location, is written to the same metadata directory. If using the example settings shown above and
112
- assuming the following directory structure exists…
79
+ The `project_roots` key defines the root level directories where your project folders are located.
80
+ When project metadata (i.e. `.sublime-project`, `.sublime-workspace`) is generated, the name of the
81
+ metadata file will be the same name as the project folder. All project metadata, regardless of root
82
+ location, is written to the same metadata directory as defined by the `metadata_dir` key. If using
83
+ the example settings shown above and assuming the following directory structure exists…
113
84
 
114
85
  ....
115
- ~/Dropbox/Development/Misc/example
116
- ~/Dropbox/Development/OSS/sublime_text_kit
86
+ ~/Engineering/OSS/example
87
+ ~/Engineering/OSS/sublime_text_kit
117
88
  ....
118
89
 
119
- …the project metadata will be created in the workspace directory as follows:
90
+ ...project metadata will be created in the `metadata_dir` as follows:
120
91
 
121
92
  ....
122
93
  ~/Dropbox/Cache/Sublime/example.sublime-project
@@ -125,25 +96,33 @@ assuming the following directory structure exists…
125
96
  ~/Dropbox/Cache/Sublime/sublime_text_kit.sublime-workspace
126
97
  ....
127
98
 
99
+ The `snippets_format` key allows you define what format to print your snippets as. The default
100
+ format is Markdown but you can switch to ASCII Doc too. You can always override your default
101
+ configuration by specifying the format from the command line: `sublime_text_kit -s ascii_doc`. For
102
+ example, this is how link:https://www.alchemists.io/projects/sublime_text_setup/#_snippets[snippets
103
+ documentation] is genereted for the
104
+ link:https://www.alchemists.io/projects/sublime_text_setup[Sublime Text Setup] project.
105
+
128
106
  === Workflow
129
107
 
130
108
  The following demonstrates a default Sublime Text setup:
131
109
 
132
- . Run: `sublime_text_kit --config --edit` (define Sublime Text Kit settings for project roots and
133
- metadata directory).
134
- . Shutdown Sublime Text (i.e. `CONTROL+Q`).
135
- . Run: `sublime_text_kit --metadata --create` (creates project metadata and rebuilds the session
136
- metadata so Sublime Text has a complete project history from which to jump through via the
137
- `CONTROL+COMMMAND+P` shortcut).
138
- . Launch Sublime Text and use the `CONTROL+COMMAND+P` keyboard shortcut to toggle between
139
- projects. Notice that you can (fuzzy type) project names to jump between them.
140
- . Breeze through your project workload with ease. 😉
110
+ 1. Start by defining your configuration: `sublime_text_kit --config edit`.
111
+ 1. Shutdown Sublime Text (i.e. `COMMAND+q`).
112
+ 1. Run `sublime_text_kit --update` which will create project metadata and rebuild session metadata
113
+ so Sublime Text has a complete project history from which to switch between via the
114
+ `CONTROL+COMMMAND+p` shortcut.
115
+ 1. Launch Sublime Text and use the `CONTROL+COMMAND+p` keyboard shortcut to toggle between projects.
116
+ Notice that you can (fuzzy type) project names to jump between them.
117
+ 1. Navigate through your project workload with ease. 🎉
141
118
 
142
119
  === Troubleshooting
143
120
 
144
- * When rebuilding workspaces, ensure Sublime Text is shutdown or changes won’t be applied.
145
- * When rebuilding workspaces, ensure workspace_dir (as defined via settings.yml) points to a
146
- directory containing `.sublime-project` and `.sublime-workspace` files.
121
+ * When rebuilding your session, ensure Sublime Text is shut down or changes might not be applied
122
+ properly.
123
+ * When rebuilding project metadata, ensure the `metadata_dir` -- as defined via your configuration
124
+ -- points to an existing directory which can contain `.sublime-project` and `.sublime-workspace`
125
+ files.
147
126
 
148
127
  == Development
149
128
 
data/bin/sublime_text_kit CHANGED
@@ -2,8 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sublime_text_kit"
5
- require "sublime_text_kit/cli"
6
- require "sublime_text_kit/identity"
7
5
 
8
6
  Process.setproctitle SublimeTextKit::Identity::VERSION_LABEL
9
- SublimeTextKit::CLI.start
7
+ SublimeTextKit::CLI::Shell.new.call ARGV
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SublimeTextKit
4
+ module CLI
5
+ module Actions
6
+ # Handles gem configuration action.
7
+ class Config
8
+ def initialize configuration: Configuration::Loader::HANDLER, container: Container
9
+ @configuration = configuration
10
+ @container = container
11
+ end
12
+
13
+ def call action
14
+ case action
15
+ when :edit then edit
16
+ when :view then view
17
+ else logger.error { "Invalid configuration action: #{action}." }
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :configuration, :container
24
+
25
+ def edit = kernel.system("$EDITOR #{configuration.current}")
26
+
27
+ def view = kernel.system("cat #{configuration.current}")
28
+
29
+ def kernel = container[__method__]
30
+
31
+ def logger = container[__method__]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/pathnames"
4
+
5
+ module SublimeTextKit
6
+ module CLI
7
+ module Actions
8
+ # Handles metadata action.
9
+ class Metadata
10
+ using Refinements::Pathnames
11
+
12
+ def initialize handler: SublimeTextKit::Metadata::Handler, container: Container
13
+ @handler = handler
14
+ @container = container
15
+ end
16
+
17
+ def call kind
18
+ case kind
19
+ when :create then create
20
+ when :delete then delete
21
+ when :recreate then recreate
22
+ else logger.error "Unknown metadata action: #{kind}."
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :handler, :container
29
+
30
+ def create
31
+ logger.info "Creating metadata in #{metadata_dir}..."
32
+ process_projects __method__
33
+ logger.info "Metadata created."
34
+ end
35
+
36
+ def delete
37
+ logger.info "Deleting metadata in #{metadata_dir}..."
38
+ process_projects __method__
39
+ logger.info "Metadata deleted."
40
+ end
41
+
42
+ def recreate
43
+ logger.info "Recreating metadata in #{metadata_dir}..."
44
+ process_projects __method__
45
+ logger.info "Metadata recreated."
46
+ end
47
+
48
+ def process_projects method
49
+ configuration.project_dirs.each do |directory|
50
+ handler.with_project(directory, metadata_dir).public_send method
51
+ handler.with_workspace(directory, metadata_dir).public_send method
52
+ end
53
+ end
54
+
55
+ def metadata_dir = Pathname(configuration.metadata_dir).expand_path
56
+
57
+ def configuration = container[__method__]
58
+
59
+ def logger = container[__method__]
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SublimeTextKit
4
+ module CLI
5
+ module Actions
6
+ # Handles session action.
7
+ class Session
8
+ def initialize rebuilder: Sessions::Rebuilder.new, container: Container
9
+ @rebuilder = rebuilder
10
+ @container = container
11
+ end
12
+
13
+ def call
14
+ rebuilder.call
15
+ logger.info "Session rebuilt."
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :rebuilder, :container
21
+
22
+ def logger = container[__method__]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SublimeTextKit
4
+ module CLI
5
+ module Actions
6
+ # Handles snippets action.
7
+ class Snippets
8
+ PRINTERS = {
9
+ ascii_doc: SublimeTextKit::Snippets::Printers::ASCIIDoc.new,
10
+ markdown: SublimeTextKit::Snippets::Printers::Markdown.new
11
+ }.freeze
12
+
13
+ def initialize printers: PRINTERS, container: Container
14
+ @printers = printers
15
+ @container = container
16
+ end
17
+
18
+ def call
19
+ kind = configuration.snippets_format
20
+ printers.fetch(kind).call
21
+ rescue KeyError
22
+ logger.error { "Invalid snippet format (must be a symbol): #{kind}. Use: #{formats}." }
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :printers, :container
28
+
29
+ def formats = printers.keys.map(&:inspect).join(" or ")
30
+
31
+ def configuration = container[__method__]
32
+
33
+ def logger = container[__method__]
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SublimeTextKit
4
+ module CLI
5
+ module Actions
6
+ # Handles update action.
7
+ class Update
8
+ def initialize metadata: SublimeTextKit::Metadata::Handler,
9
+ session: Sessions::Rebuilder.new,
10
+ container: Container
11
+ @metadata = metadata
12
+ @session = session
13
+ @container = container
14
+ end
15
+
16
+ def call
17
+ logger.info "Updating metadata and session..."
18
+ create_metadata
19
+ session.call
20
+ logger.info "Metadata and session updated."
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :metadata, :session, :container
26
+
27
+ def create_metadata
28
+ configuration.project_dirs.each do |directory|
29
+ metadata.with_project(directory, metadata_dir).create
30
+ metadata.with_workspace(directory, metadata_dir).create
31
+ end
32
+ end
33
+
34
+ def metadata_dir = Pathname(configuration.metadata_dir).expand_path
35
+
36
+ def configuration = container[__method__]
37
+
38
+ def logger = container[__method__]
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/pathnames"
4
+
5
+ module SublimeTextKit
6
+ module CLI
7
+ module Configuration
8
+ # Defines configuration content as the primary source of truth for use throughout the gem.
9
+ Content = Struct.new(
10
+ :action_config,
11
+ :action_help,
12
+ :action_metadata,
13
+ :action_session,
14
+ :action_snippets,
15
+ :action_update,
16
+ :action_version,
17
+ :project_roots,
18
+ :metadata_dir,
19
+ :snippets_format,
20
+ :session_path,
21
+ :user_dir,
22
+ keyword_init: true
23
+ ) do
24
+ using Refinements::Pathnames
25
+
26
+ def initialize *arguments
27
+ super
28
+
29
+ home = Pathname ENV["HOME"]
30
+
31
+ self[:session_path] ||= home.join(
32
+ "Library/Application Support/Sublime Text/Local/Session.sublime_session"
33
+ )
34
+
35
+ self[:user_dir] ||= home.join "Library/Application Support/Sublime Text/Packages/User"
36
+ end
37
+
38
+ def project_dirs
39
+ Array(project_roots).map { |path| Pathname(path).expand_path }
40
+ .flat_map(&:directories)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ :project_roots:
2
+ :metadata_dir:
3
+ :snippets_format: :markdown
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "refinements/hashes"
5
+ require "refinements/structs"
6
+ require "runcom"
7
+ require "yaml"
8
+
9
+ module SublimeTextKit
10
+ module CLI
11
+ module Configuration
12
+ # Represents the fully assembled Command Line Interface (CLI) configuration.
13
+ class Loader
14
+ using Refinements::Hashes
15
+ using Refinements::Structs
16
+
17
+ DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
18
+ HANDLER = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
19
+
20
+ def self.call = new.call
21
+
22
+ def self.with_defaults = new(handler: DEFAULTS)
23
+
24
+ def initialize content: Content.new, handler: HANDLER
25
+ @content = content
26
+ @handler = handler
27
+ end
28
+
29
+ def call = content.merge(**handler.to_h.flatten_keys)
30
+
31
+ private
32
+
33
+ attr_reader :content, :handler
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "runcom"
4
+
5
+ module SublimeTextKit
6
+ module CLI
7
+ module Parsers
8
+ # Assembles and parses all Command Line Interface (CLI) options.
9
+ class Assembler
10
+ def initialize section: Core, client: CLIENT, container: Container
11
+ @section = section
12
+ @client = client
13
+ @container = container
14
+ end
15
+
16
+ def call arguments = []
17
+ section.call client: client
18
+ client.parse! arguments
19
+ configuration
20
+ end
21
+
22
+ def to_s = client.to_s
23
+
24
+ private
25
+
26
+ attr_reader :section, :client, :container
27
+
28
+ def configuration = container[__method__]
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "versionaire/extensions/option_parser"
4
+
5
+ module SublimeTextKit
6
+ module CLI
7
+ # Handles parsing of Command Line Interface (CLI) primary options.
8
+ module Parsers
9
+ # Handles parsing of Command Line Interface (CLI) core options.
10
+ class Core
11
+ def self.call(...) = new(...).call
12
+
13
+ def initialize client: CLIENT, container: Container
14
+ @client = client
15
+ @container = container
16
+ end
17
+
18
+ def call arguments = []
19
+ client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
20
+ client.separator "\nUSAGE:\n"
21
+ collate
22
+ arguments.empty? ? arguments : client.parse!(arguments)
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :client, :container
28
+
29
+ def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
30
+
31
+ def add_config
32
+ client.on(
33
+ "-c",
34
+ "--config ACTION",
35
+ %i[edit view],
36
+ "Manage gem configuration. Actions: edit or view."
37
+ ) do |action|
38
+ configuration.action_config = action
39
+ end
40
+ end
41
+
42
+ def add_metadata
43
+ client.on(
44
+ "-m",
45
+ "--metadata ACTION",
46
+ %i[create delete recreate],
47
+ "Manage project metadata. Actions: create, delete, or recreate."
48
+ ) do |action|
49
+ configuration.action_metadata = action
50
+ end
51
+ end
52
+
53
+ def add_session
54
+ client.on "-S", "--session", "Rebuild session metadata." do
55
+ configuration.action_session = true
56
+ end
57
+ end
58
+
59
+ def add_snippets
60
+ client.on(
61
+ "-s",
62
+ "--snippets [FORMAT]",
63
+ %i[markdown ascii_doc],
64
+ "View snippets. Default: #{configuration.snippets_format}. " \
65
+ "Formats: markdown or ascii_doc."
66
+ ) do |kind|
67
+ configuration.action_snippets = true
68
+ configuration.snippets_format = kind if kind
69
+ end
70
+ end
71
+
72
+ def add_update
73
+ client.on(
74
+ "-u",
75
+ "--update",
76
+ "Update project and session metadata based on current settings."
77
+ ) do
78
+ configuration.action_update = true
79
+ end
80
+ end
81
+
82
+ def add_version
83
+ client.on "-v", "--version", "Show gem version." do
84
+ configuration.action_version = Identity::VERSION_LABEL
85
+ end
86
+ end
87
+
88
+ def add_help
89
+ client.on "-h", "--help", "Show this message." do
90
+ configuration.action_help = true
91
+ end
92
+ end
93
+
94
+ private_methods
95
+
96
+ def configuration = container[__method__]
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ module SublimeTextKit
6
+ module CLI
7
+ module Parsers
8
+ CLIENT = OptionParser.new nil, 40, " "
9
+ end
10
+ end
11
+ end