pagecord-cli 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e79c8864b73579755f1699da00835d474cae8871b64c5ff21e091d4540e95be
4
- data.tar.gz: bbdc8963f7317ec56f55de326898021d1bf5712f15c8833c83f6ccbac533f06f
3
+ metadata.gz: 99eebd4d84788c1c5176bca0d7b1f036bb54ec2acb9e5f6a9f9fef7b63fc5d1d
4
+ data.tar.gz: 78d6e0b1623c066f1b9f992cf87e7e80c997ef7abfa2d2f4e6893ba6e34c0f8f
5
5
  SHA512:
6
- metadata.gz: b6dab32f1f4884be02388a220d441fbe21041940d5f3c4a6e607ce4c9ff4c60d12582ae9f60435cbcf87b3e3645f9fd58cc144a55b4b453bd2a9f628cde3c0a3
7
- data.tar.gz: 208af262450558105da20a6006cf70340e804ad6c4fadf4dbab05aada82a572efd0f5af01cfd12cdec2d1b20511473407d00d5f87c51d1ae36e6b45bebbde3ef
6
+ metadata.gz: 27842bcc27c07553c69ee4664aad327ab1d1f6155b3eaccc64d66fbcc699d73d543ae09bf2b406f568e6fca1eab83e0976d8f0ed08f62bd30ec63f57e5836796
7
+ data.tar.gz: 245f7e50410b5b93daca45d14ead9268f447cd9bada1bf580db1c73d3c5ec5d39207f7dacbf09fb21c98cc2debfba5d0b97f39b8e3b931b2d183dee9ead935cd
data/README.md CHANGED
@@ -22,7 +22,7 @@ The name should be your Pagecord subdomain. The API key is stored in
22
22
  For local testing there is an undocumented `--base-url` option:
23
23
 
24
24
  ```bash
25
- pagecord login myblog --base-url http://localhost:3000
25
+ pagecord login myblog --base-url http://api.localhost:3000
26
26
  ```
27
27
 
28
28
  ## Publishing
@@ -42,13 +42,6 @@ pagecord draft notes/idea.md
42
42
  The first publish creates a post and writes Pagecord metadata back into the
43
43
  file. Later publishes update the same post.
44
44
 
45
- If you have one blog configured, `publish`, `draft`, and `logout` can omit the
46
- subdomain. If you have more than one, pass the subdomain as the final argument:
47
-
48
- ```bash
49
- pagecord publish hello.md myblog
50
- ```
51
-
52
45
  See configured blogs:
53
46
 
54
47
  ```bash
@@ -63,16 +56,26 @@ pagecord logout myblog
63
56
 
64
57
  ## Choosing a blog
65
58
 
66
- With several blogs configured, pick a default once:
59
+ With one blog configured, every command uses it. With several, set a default
60
+ once:
67
61
 
68
62
  ```bash
69
63
  pagecord blog use myblog
70
64
  ```
71
65
 
72
- Every command works out which blog to use in this order: the subdomain passed
73
- as a positional argument, then `--blog myblog`, then the `PAGECORD_BLOG`
74
- environment variable, then the default set by `pagecord blog use`, and finally
75
- the only configured blog if there is just one.
66
+ or name the blog on the command line:
67
+
68
+ ```bash
69
+ pagecord appearance show --blog myblog
70
+ ```
71
+
72
+ `--blog` wins over the `PAGECORD_BLOG` environment variable, which wins over
73
+ the default. `publish`, `draft` and `logout` also take the subdomain as a
74
+ trailing argument, which wins over all three:
75
+
76
+ ```bash
77
+ pagecord publish hello.md myblog
78
+ ```
76
79
 
77
80
  ## Appearance
78
81
 
@@ -247,12 +247,12 @@ module PagecordCLI
247
247
  end
248
248
 
249
249
  def resolve_blog(name = nil)
250
- raise Error, "No blogs are configured. Run pagecord login SUBDOMAIN first." if config.blogs.empty?
250
+ raise Error, "No blogs are configured. Run `pagecord login SUBDOMAIN` first." if config.blogs.empty?
251
251
 
252
252
  subdomain = name || options[:blog] || ENV["PAGECORD_BLOG"] || config.default_blog ||
253
253
  (config.blogs.keys.first if config.blogs.size == 1)
254
254
 
255
- raise Error, "Please specify a subdomain" unless subdomain
255
+ raise Error, "Several blogs are configured. Pass `--blog SUBDOMAIN`, or run `pagecord blog use SUBDOMAIN` to set a default." unless subdomain
256
256
  raise Error, "Unknown blog: #{subdomain}" unless config.blog(subdomain)
257
257
 
258
258
  subdomain
@@ -310,15 +310,14 @@ module PagecordCLI
310
310
  pagecord appearance show
311
311
  pagecord appearance update [options]
312
312
  pagecord custom-code show [--css|--footer-html|--head-html|--body-html]
313
- pagecord custom-code update --css blog.css
314
313
  pagecord custom-code update [options]
315
314
  pagecord publish FILE [SUBDOMAIN] [options]
316
315
  pagecord draft FILE [SUBDOMAIN] [options]
317
316
 
318
317
  Global options:
319
- --blog SUBDOMAIN
320
- --json
321
- --quiet
318
+ --blog SUBDOMAIN which blog to act on
319
+ --json machine-readable output
320
+ --quiet suppress confirmation messages
322
321
 
323
322
  Publish options:
324
323
  --title TITLE
@@ -80,7 +80,15 @@ module PagecordCLI
80
80
 
81
81
  def request(http_request)
82
82
  http_request["Authorization"] ||= "Bearer #{api_key}"
83
- response = Net::HTTP.start(http_request.uri.hostname, http_request.uri.port, use_ssl: http_request.uri.scheme == "https") do |http|
83
+ uri = http_request.uri
84
+ address = uri.hostname
85
+ if address.end_with?(".localhost")
86
+ # *.localhost is loopback by definition (RFC 6761); macOS does not resolve it
87
+ http_request["Host"] = "#{uri.host}:#{uri.port}"
88
+ address = "127.0.0.1"
89
+ end
90
+
91
+ response = Net::HTTP.start(address, uri.port, use_ssl: uri.scheme == "https") do |http|
84
92
  http.open_timeout = OPEN_TIMEOUT
85
93
  http.read_timeout = READ_TIMEOUT
86
94
  http.write_timeout = WRITE_TIMEOUT if http.respond_to?(:write_timeout=)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PagecordCLI
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagecord-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olly Headey