playwright-cli 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +177 -14
  3. data/lib/playwright/cli/version.rb +2 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c70812c6e97a5e0351036b1f32cc533e7833d59ad46c32efb16b6cdc8e167023
4
- data.tar.gz: c39ef6a202fed3feeb7015d1f0adbfdfe29fd42f41a4493555e4e67b28f2d5d0
3
+ metadata.gz: 77a1822555e09c749d2408b29496ca5840553bd45decf3c1f24ee8f87448e8e0
4
+ data.tar.gz: a97277bfb37d67ad68099f362db4c3fd2c5a8243da676b727723f7b703cda2fa
5
5
  SHA512:
6
- metadata.gz: bbffdc6bdb10897709564e578ea6b9312dd2a2c0f8a468a5c80b9a7d0e98624c5a5fcc72bfef381ca55492d3bbcfa4b54a24bce7e6e8d50d0bb606ba3c22ac36
7
- data.tar.gz: 2c93bab7b6fc00a73d48fc5f3eae2f332ae8ec1cd9468bc8aa9998269381d6a343fbe7d6287156e982d2e4671c6e57e956acbb9a6b4cbf38fa7db3aee787d4e9
6
+ metadata.gz: 2fc6645dc4cbd4305c35caea58c1c50ca7335f875eb2d7c490428bb6314e03d93b0f3437ed1f4ca0007f2c2affaa3bd741df3d6d39c73db3e042b19862128ca4
7
+ data.tar.gz: 66ca9d2e2ef45e96e449b0bf41593ecf483b1bbf45084b2ab5a71508df5526d5a3936be6731080a3b212474ae1bf8f9017a8ec441017cb85f48cbc5dfb973cd9
data/README.md CHANGED
@@ -1,34 +1,197 @@
1
1
  # Playwright::CLI
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/playwright/cli`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Playwright::CLI is a tool for quickly building (and hopefully soon sharing)
4
+ Ruby command line applications. It's first goal is to provide a solid generator
5
+ for building command line apps in Ruby. It's built on top of [Hanami::CLI](https://github.com/hanami/cli),
6
+ so all of their documentation applies here as well.
6
7
 
7
8
  ## Installation
8
9
 
9
- Add this line to your application's Gemfile:
10
+ Install this gem with:
11
+
12
+ $ gem install playwright-cli
13
+
14
+ ## Usage
15
+
16
+ ### Check The Version
17
+
18
+ To check the version:
19
+ ```shell
20
+ $ playwright -v #=> 0.1.4
21
+ ```
22
+
23
+ ### Create An App
24
+
25
+ To create a simple command line app:
26
+
27
+ $ playwright generate my-script
28
+
29
+ (aliases for `generate` include `g`, `new`)
30
+ This will give you some boilerplate for your script and an example command that
31
+ you should replace. It will look something like this:
10
32
 
11
33
  ```ruby
12
- gem 'playwright-cli'
34
+ #!/usr/bin/env ruby
35
+
36
+ require 'playwright/cli'
37
+
38
+ module MyScript
39
+ module CLI
40
+ module Commands
41
+ extend Playwright::CLI::Registry
42
+
43
+ class Root < Playwright::CLI::Command
44
+ desc "Says a greeting to the name given. This is an example."
45
+
46
+ argument :name, required: true, desc: 'Whom shall I greet?'
47
+
48
+ example [
49
+ "\"Johnny Boy\" #=> Why, hello Johnny Boy!"
50
+ ]
51
+
52
+ def call(name:, **)
53
+ puts "Why, hello #{name}!"
54
+ end
55
+
56
+ end
57
+
58
+ register_root Root
59
+
60
+ end
61
+ end
62
+ end
63
+
64
+ Playwright::CLI.new(MyScript::CLI::Commands).call
65
+
66
+ ```
67
+
68
+ Most of this code is simply wrapping [Hanami::CLI](https://github.com/hanami/cli), so their documentation
69
+ will be the best source of information for you in handling arguments and options.
70
+
71
+ So far, only `#register_root` here is a playwright feature. It allows you to
72
+ overwrite the root command. In this case that means:
73
+ ```shell
74
+ $ my-script tom #=> Why, hello tom!
75
+ ```
76
+
77
+ Hanami::CLI is built for more intricate command line apps, so playwright allows
78
+ you to generate that as well.
79
+ ```shell
80
+ $ playwright g my-script --type=expanded
13
81
  ```
82
+ This will give you a mostly similar main class:
14
83
 
15
- And then execute:
84
+ ```ruby
85
+ #!/usr/bin/env ruby
16
86
 
17
- $ bundle
87
+ require 'playwright/cli'
88
+ require_relative 'lib/version'
18
89
 
19
- Or install it yourself as:
90
+ module MyScript
91
+ module CLI
92
+ module Commands
93
+ extend Playwright::CLI::Registry
20
94
 
21
- $ gem install playwright-cli
95
+ class Greet < Playwright::CLI::Command
96
+ desc "Says a greeting to the name given. This is an example."
22
97
 
23
- ## Usage
98
+ argument :name, required: true, desc: 'Whom shall I greet?'
99
+
100
+ example [
101
+ "\"Johnny Boy\" #=> Why, hello Johnny Boy!"
102
+ ]
24
103
 
25
- TODO: Write usage instructions here
104
+ def call(name:, **)
105
+ puts "Why, hello #{name}!"
106
+ end
26
107
 
27
- ## Development
108
+ end
28
109
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
110
+ register 'greet', Greet
111
+ register 'version', Version, aliases: ['v', '-v', '--version']
112
+
113
+ end
114
+ end
115
+ end
116
+
117
+ Playwright::CLI.new(MyScript::CLI::Commands).call
118
+ ```
119
+ It will also give you a new file structure with an example (version) command:
120
+ ```
121
+ my-script
122
+ |- lib/
123
+ | |- version.rb
124
+ |- my-script.rb
125
+ ```
126
+ The main differences are that a new file lib/version is required and registered
127
+ with aliases.
128
+
129
+ Version class simply looks like this:
130
+ ```ruby
131
+ module MyScript
132
+ module CLI
133
+
134
+ VERSION = "0.0.1"
135
+
136
+ module Commands
137
+ extend Playwright::CLI::Registry
138
+
139
+ class Version < Playwright::CLI::Command
140
+ desc "Responds with the version number."
141
+
142
+ example ["#=> #{VERSION}"]
143
+
144
+ def call(**)
145
+ puts VERSION
146
+ end
147
+
148
+ end
149
+
150
+ end
151
+ end
152
+ end
153
+ ```
154
+
155
+ This is useful for command line apps that will have multiple functions. This
156
+ example would let you do:
157
+
158
+ ```shell
159
+ $ my-script greet tom #=> Why, hello tom!
160
+ $ my-script version #=> 0.0.1
161
+ ```
162
+
163
+
164
+ ### Edit An App
165
+
166
+ Playwright::CLI uses your `$EDITOR` environment variable when choosing what
167
+ editor to use when opening one of your playwright scripts.
168
+
169
+ Use:
170
+
171
+ `$ echo $EDITOR`
172
+
173
+ To see what playwright will default to. You can update this in your ~/.bashrc
174
+ (or ~/.zshrc if you are using zsh).
175
+
176
+ In the future, I plan on allowing that to be a config you can set
177
+
178
+ To edit an app:
179
+
180
+ `$ playwright edit my-script`
181
+
182
+ `e` can be used instead of `edit`.
183
+
184
+ ### Delete An App
185
+
186
+ Deleting a playwright app is simply:
187
+
188
+ ```shell
189
+ $ playwright destroy my-script
190
+ ```
30
191
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
192
+ `delete` or `d` can be used instead of `destroy`
193
+ This works for both simple and expanded apps. It cannot be used to delete or
194
+ uninstall existing terminal commands, only playwright commands
32
195
 
33
196
  ## Contributing
34
197
 
@@ -1,5 +1,5 @@
1
1
  module Playwright
2
2
  class CLI < Hanami::CLI
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.5"
4
4
  end
5
- end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Gregory