edify-cli 0.3.0 → 0.4.0

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: 52b26c0e847bced6de074790b98a079cef541659ef205ff084234f4d472e4cc6
4
- data.tar.gz: 18a48efbd67f5e6f3a288e3d9b567f76bf356e1c644fc1bbe22b14414b12f75e
3
+ metadata.gz: dd6e4830985f4fa137b9f1dc70488f4c21b10c3d0f56f2600ddd589475311997
4
+ data.tar.gz: f77c50dd337d71b77d89e0ff939a08e70d4ec7248b6d2454a237bbfe5f9e145d
5
5
  SHA512:
6
- metadata.gz: b71b13e91b670e0fd6e05e0e8614b948eeb8e11d0cab3060f20469d95209611dfab39d6814fa5a37648709c66e48917ca9e744b344b867a3e9a676a194a911e5
7
- data.tar.gz: 447d675606095d0a43ad2ca85e7184b223297870c15b42c21b6b217df3fb6fab52210971b974249c285ab92a26608c040e502fb5dfdd5d12a97df69569fcb5c1
6
+ metadata.gz: 61f9914b4d53d2e40393eb48e8d9df91c5016a60c8c932eb60861c02b1e98d2780ec1ddefe0ad4755a5175d04e91bd475dcf97a8980f78e67197fea1f3437132
7
+ data.tar.gz: cabd28e583e110fde3daa8eef6ecbd0631c9a39cddb440b1b3cc59077f48a32e503e90f3f3e5396fccb22653f776c6b1922b437e1c31b11e463830b8d9303bbe
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to edify-cli are recorded here. The format follows [Keep a C
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.4.0] - 2026-11-23
8
+
9
+ ### Added
10
+
11
+ - `edify members search QUERY [--limit N]`: members whose name contains every word of the query, with gender and age group. Explains which roles can search when yours can't (#17).
12
+ - `edify talks list [--speaker WORDS] [--purpose TEXT] [--from DATE] [--to DATE] [--limit N]`: your unit's talks, newest first, with date, speaker, purpose and topic (#20).
13
+
7
14
  ## [0.3.0] - 2026-11-23
8
15
 
9
16
  ### Added
@@ -33,7 +40,8 @@ All notable changes to edify-cli are recorded here. The format follows [Keep a C
33
40
  - `--json` on data commands, `EDIFY_TOKEN` and `EDIFY_URL` overrides, and API errors on stderr with exit status 1 (#2, #3).
34
41
  - The login is saved with owner-only permissions, and the token is sent only over HTTPS, except to localhost (#2).
35
42
 
36
- [Unreleased]: https://github.com/edifyapporg/edify-cli/compare/v0.3.0...HEAD
43
+ [Unreleased]: https://github.com/edifyapporg/edify-cli/compare/v0.4.0...HEAD
44
+ [0.4.0]: https://github.com/edifyapporg/edify-cli/compare/v0.3.0...v0.4.0
37
45
  [0.3.0]: https://github.com/edifyapporg/edify-cli/compare/v0.2.0...v0.3.0
38
46
  [0.2.0]: https://github.com/edifyapporg/edify-cli/compare/v0.1.0...v0.2.0
39
47
  [0.1.0]: https://github.com/edifyapporg/edify-cli/releases/tag/v0.1.0
data/README.md CHANGED
@@ -94,6 +94,37 @@ Dates are written `YYYY-MM-DD`. Both commands take `--json`.
94
94
 
95
95
  Songs and meetings are available to every role in your unit.
96
96
 
97
+ ### `edify members search QUERY`
98
+
99
+ Finds members of your unit whose name contains every word of QUERY, in any order. Names are recorded as "Last, First", so this finds "Smith, Jane":
100
+
101
+ ```sh
102
+ $ edify members search jane smith
103
+ NAME GENDER GROUP
104
+ Smith, Jane female adult
105
+ ```
106
+
107
+ Shows name, gender and age group only. `--limit N` (1 to 100, default 25) and `--json` work as elsewhere. Needs a bishopric or clerk role, the same roles that see the Members page in Edify.
108
+
109
+ ### `edify talks list`
110
+
111
+ Your unit's sacrament meeting talks, newest first, with the meeting date, speaker, purpose and topic. Long topics are shortened in the table, and `--json` has them in full.
112
+
113
+ ```sh
114
+ $ edify talks list --speaker "jane smith"
115
+ $ edify talks list --purpose missionary --from 2026-01-01
116
+ ```
117
+
118
+ | Option | Meaning |
119
+ |---|---|
120
+ | `--speaker WORDS` | Every word must appear in the speaker's name ("Last, First") |
121
+ | `--purpose TEXT` | Part of the purpose, e.g. `missionary` or `youth` |
122
+ | `--from DATE`, `--to DATE` | Meeting dates to include, `YYYY-MM-DD` |
123
+ | `--limit N` | Most talks to list, 1 to 200 (default 50) |
124
+ | `--json` | Print the API's JSON instead of a table |
125
+
126
+ Needs a bishopric or clerk role, the same roles that see the Talks page in Edify.
127
+
97
128
  ### Other commands
98
129
 
99
130
  - `edify status`, `edify logout` (see [Log in](#log-in))
data/lib/edify/cli.rb CHANGED
@@ -6,8 +6,10 @@ require_relative "client"
6
6
  require_relative "table"
7
7
  require_relative "commands/helpers"
8
8
  require_relative "commands/meetings"
9
+ require_relative "commands/members"
9
10
  require_relative "commands/songs"
10
11
  require_relative "commands/speakers"
12
+ require_relative "commands/talks"
11
13
 
12
14
  module Edify
13
15
  # The `edify` command. Every command reads from the Edify API with a personal access token, created in Edify under
@@ -83,6 +85,12 @@ module Edify
83
85
  desc "meetings SUBCOMMAND", "Questions about meetings"
84
86
  subcommand "meetings", Commands::Meetings
85
87
 
88
+ desc "members SUBCOMMAND", "Find members"
89
+ subcommand "members", Commands::Members
90
+
91
+ desc "talks SUBCOMMAND", "Questions about talks"
92
+ subcommand "talks", Commands::Talks
93
+
86
94
  URL_SOURCES = { env: "from EDIFY_URL", saved: "from the saved login", default: "the default" }.freeze
87
95
 
88
96
  private
@@ -5,6 +5,9 @@ module Edify
5
5
  # Shared by every command class: reading the saved login, calling the API, and printing JSON. Errors become
6
6
  # Thor::Error, which Thor prints to stderr before exiting with status 1.
7
7
  module Helpers
8
+ # Dates are checked against this before any request, so a date argument can never put anything else into a
9
+ # request path or query.
10
+ ISO_DATE_PATTERN = /\A\d{4}-\d{2}-\d{2}\z/
8
11
  NOT_LOGGED_IN = "Not logged in. Run `edify login`, or set EDIFY_TOKEN.".freeze
9
12
  RELOGIN_HINT = "Your token may have been revoked or expired. Create a new one in Edify under " \
10
13
  "Settings > API Tokens, then run `edify login`.".freeze
@@ -23,21 +26,27 @@ module Edify
23
26
  raise Thor::Error, e.message
24
27
  end
25
28
 
26
- # @param not_found [String, nil] a message to show instead of the API's generic one when it answers not_found
29
+ # @param messages [Hash{String => String}] messages to show instead of the API's own, by error code, e.g.
30
+ # { "not_found" => "No meeting on 2026-11-23." }
27
31
  # @param params [Hash] query parameters; nil values are left out
28
32
  # @return [Hash] the API's response body
29
- def api_get(path, not_found: nil, **params)
33
+ def api_get(path, messages: {}, **params)
30
34
  client.get(path, params)
31
35
  rescue Client::Error => e
32
- raise Thor::Error, error_message(e, not_found)
36
+ raise Thor::Error, error_message(e, messages)
33
37
  end
34
38
 
35
- def error_message(error, not_found)
36
- case error.code
37
- when "invalid_token" then "#{error.message}\n#{RELOGIN_HINT}"
38
- when "not_found" then not_found || error.message
39
- else error.message
40
- end
39
+ def error_message(error, messages)
40
+ return "#{error.message}\n#{RELOGIN_HINT}" if error.code == "invalid_token"
41
+
42
+ messages.fetch(error.code, error.message)
43
+ end
44
+
45
+ # @param name [Symbol] :date for a DATE argument, or the option's name, e.g. :from
46
+ def check_date!(name, value)
47
+ return if value.to_s.match?(ISO_DATE_PATTERN)
48
+
49
+ raise Thor::Error, "#{name == :date ? 'DATE' : "--#{name}"} must be a date written as YYYY-MM-DD."
41
50
  end
42
51
 
43
52
  def print_json(body)
@@ -3,8 +3,6 @@ module Edify
3
3
  class Meetings < Thor
4
4
  include Helpers
5
5
 
6
- # Checked before any request, so a date argument can never put anything else into a request path.
7
- ISO_DATE = /\A\d{4}-\d{2}-\d{2}\z/
8
6
  CONTRIBUTOR_LABELS = {
9
7
  "presider" => "Presiding",
10
8
  "conductor" => "Conducting",
@@ -50,7 +48,7 @@ module Edify
50
48
  def show(date)
51
49
  check_date!(:date, date)
52
50
 
53
- body = api_get("meetings/#{date}", not_found: "No meeting on #{date}.")
51
+ body = api_get("meetings/#{date}", messages: { "not_found" => "No meeting on #{date}." })
54
52
  return print_json(body) if options[:json]
55
53
 
56
54
  say "#{body['date']} #{humanize(body['meeting_type'])}"
@@ -61,12 +59,6 @@ module Edify
61
59
 
62
60
  private
63
61
 
64
- def check_date!(name, value)
65
- return if value.to_s.match?(ISO_DATE)
66
-
67
- raise Thor::Error, "#{name == :date ? 'DATE' : "--#{name}"} must be a date written as YYYY-MM-DD."
68
- end
69
-
70
62
  def contributor_lines(contributors)
71
63
  CONTRIBUTOR_LABELS.filter_map { |key, label| "#{label}: #{contributors[key]}" if contributors[key] }
72
64
  end
@@ -0,0 +1,36 @@
1
+ module Edify
2
+ module Commands
3
+ class Members < Thor
4
+ include Helpers
5
+
6
+ FORBIDDEN = "Member search needs a bishopric or clerk role in Edify, " \
7
+ "the same roles that see the Members page.".freeze
8
+
9
+ def self.exit_on_failure?
10
+ true
11
+ end
12
+
13
+ desc "search QUERY", "Find members by name"
14
+ long_desc <<~DESC
15
+ Finds members of your unit whose name contains every word of QUERY, in any order and ignoring case. Names are
16
+ recorded as "Last, First", so `edify members search jane smith` finds "Smith, Jane". Shows name, gender and
17
+ age group only.
18
+ DESC
19
+ option :limit, type: :numeric, desc: "Most members to list (1-100, default 25)"
20
+ option :json, type: :boolean, default: false, desc: "Print the API's JSON instead of a table"
21
+ def search(*words)
22
+ raise Thor::Error, "Give part of a name to search for, e.g. `edify members search smith`." if words.empty?
23
+
24
+ query = words.join(" ")
25
+ body = api_get("members", q: query, limit: options[:limit], messages: { "forbidden" => FORBIDDEN })
26
+ return print_json(body) if options[:json]
27
+
28
+ members = body.fetch("members")
29
+ return say("No members match \"#{body['query']}\".") if members.empty?
30
+
31
+ rows = members.map { |m| [m["name"], m["gender"], m["group"]] }
32
+ say Table.render(%w[NAME GENDER GROUP], rows)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,51 @@
1
+ module Edify
2
+ module Commands
3
+ class Talks < Thor
4
+ include Helpers
5
+
6
+ FORBIDDEN = "Listing talks needs a bishopric or clerk role in Edify, " \
7
+ "the same roles that see the Talks page.".freeze
8
+ # Long topics are cut short in the table; --json always has the whole topic.
9
+ TOPIC_WIDTH = 50
10
+
11
+ def self.exit_on_failure?
12
+ true
13
+ end
14
+
15
+ desc "list", "List talks, newest first"
16
+ long_desc <<~DESC
17
+ Lists your unit's sacrament meeting talks, newest first, with the meeting date, speaker, purpose and topic.
18
+ Filters can be combined: --speaker (every word must appear in the speaker's name, recorded as "Last, First"),
19
+ --purpose (part of the purpose, e.g. "missionary"), and --from and --to (meeting dates, YYYY-MM-DD).
20
+ DESC
21
+ option :speaker, desc: "Words from the speaker's name"
22
+ option :purpose, desc: "Text the purpose contains, e.g. missionary"
23
+ option :from, desc: "First meeting date, YYYY-MM-DD"
24
+ option :to, desc: "Last meeting date, YYYY-MM-DD"
25
+ option :limit, type: :numeric, desc: "Most talks to list (1-200, default 50)"
26
+ option :json, type: :boolean, default: false, desc: "Print the API's JSON instead of a table"
27
+ def list
28
+ check_date!(:from, options[:from]) if options[:from]
29
+ check_date!(:to, options[:to]) if options[:to]
30
+
31
+ body = api_get("talks", speaker: options[:speaker], purpose: options[:purpose], from: options[:from],
32
+ to: options[:to], limit: options[:limit], messages: { "forbidden" => FORBIDDEN })
33
+ return print_json(body) if options[:json]
34
+
35
+ talks = body.fetch("talks")
36
+ return say("No talks match.") if talks.empty?
37
+
38
+ rows = talks.map { |t| [t["date"], t["speaker"], t["purpose"], shorten(t["topic"])] }
39
+ say Table.render(%w[DATE SPEAKER PURPOSE TOPIC], rows)
40
+ end
41
+
42
+ private
43
+
44
+ def shorten(text)
45
+ return text if text.nil? || text.length <= TOPIC_WIDTH
46
+
47
+ "#{text[0, TOPIC_WIDTH - 3].rstrip}..."
48
+ end
49
+ end
50
+ end
51
+ end
data/lib/edify/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Edify
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Oveson
@@ -38,8 +38,10 @@ files:
38
38
  - lib/edify/client.rb
39
39
  - lib/edify/commands/helpers.rb
40
40
  - lib/edify/commands/meetings.rb
41
+ - lib/edify/commands/members.rb
41
42
  - lib/edify/commands/songs.rb
42
43
  - lib/edify/commands/speakers.rb
44
+ - lib/edify/commands/talks.rb
43
45
  - lib/edify/config.rb
44
46
  - lib/edify/table.rb
45
47
  - lib/edify/version.rb