lexdrill 0.16.0 → 0.17.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: 36e9bb140cbbb757b2c9703b8cd122a9fd62a3faa108c4cc0072755391acb65f
4
- data.tar.gz: b3502832141a5b7e751f69c5b6d8e729c640f5896300053b96f99fe068968b73
3
+ metadata.gz: 90fae028c5269ace52ee6fadc58941617f30b35a4d47f42c0654fcb88a478dd8
4
+ data.tar.gz: d1744556c29c18a5cf8f3b2ed8e23e2b4660bf3b0455bbde57abb1f29f954035
5
5
  SHA512:
6
- metadata.gz: f89f5aa67e5ad3170d1cd956a4c0d53ffca66993f5b94ad55a3f9ef6e32bbaa8befb8d522e03506c761826a4273b1f86f72c4e92c2230c6d2c4b2906149bb70b
7
- data.tar.gz: ac7a2afdfbdff3fe694b4ec90f30eaa7c418707a9370697033cadabf0d2b389f68f5356404ab62afbff30f685d16316399777721861ffe31c2e95970047d974f
6
+ metadata.gz: c8df12b5210838e036736c62940ca427d07e490da114145fc798dc3d37b8f915c0ed70ab550e287502999ac450491c7539f68589cc37fe5790693c39fb587d66
7
+ data.tar.gz: ab045c1f53749f1e0654d70a614b5a9ab5699984dd39d5578a742a42d174be74edb1119eb2404c2613e56992263a85922dbcdef69794c1fd768badb0ae057805
data/README.md CHANGED
@@ -299,5 +299,6 @@ itself automatically).
299
299
  | `drill go <number>` | Jump so the next `drill next` shows item `<number>` (1-based, see `drill list`) — prints nothing itself; refuses a graduated item; has no effect while `drill beat rand` is active, since that mode ignores the counter entirely |
300
300
  | `drill remote <url>` | Set the Google Sheet used by the service account flow (global, parses the spreadsheet id out of a normal share URL); whichever of `drill remote`/`drill oauth` was set more recently wins |
301
301
  | `drill oauth <url>` | Set the Google Sheet used by the OAuth (personal-login) flow (global, parses the spreadsheet id out of a normal share URL); whichever of `drill remote`/`drill oauth` was set more recently wins |
302
+ | `drill sheet` | Print a link to whichever spreadsheet (`drill remote`/`drill oauth`) is currently active |
302
303
  | `drill export <sheet-name>` | Export the word list text to the named tab (created if it doesn't exist), overwriting it; uses whichever of `drill remote`/`drill oauth` was configured most recently (first OAuth use triggers a one-time Google device-flow sign-in) |
303
304
  | `drill import <sheet-name>` | Replace the local word list with column A of the named tab |
data/lib/lexdrill/cli.rb CHANGED
@@ -20,6 +20,7 @@ class Lexdrill::CLI
20
20
  run_go: %w[go],
21
21
  run_remote: %w[remote],
22
22
  run_oauth: %w[oauth],
23
+ run_sheet: %w[sheet],
23
24
  run_export: %w[export],
24
25
  run_import: %w[import]
25
26
  }.freeze
@@ -76,6 +77,7 @@ class Lexdrill::CLI
76
77
  drill remote <url> Set the Google Sheet used by a local service account key
77
78
  (~/.drill.gcp-service-account.json) — no interactive sign-in
78
79
  drill oauth <url> Set the Google Sheet used by the OAuth (personal-login) flow
80
+ drill sheet Print a link to the currently active spreadsheet
79
81
  drill export <sheet-name> Export the word list text to the given tab (overwrites its
80
82
  contents); uses whichever of drill remote/drill oauth was set
81
83
  more recently (oauth opens a one-time sign-in on first use)
@@ -343,9 +345,17 @@ class Lexdrill::CLI
343
345
  # either command always takes effect. Returns [spreadsheet_id,
344
346
  # access_token], or nil if neither is configured.
345
347
  def sheets_target
346
- case latest_remote_kind
347
- when :remote then [Lexdrill::Remote.spreadsheet_id, Lexdrill::ServiceAccountAuth.fetch_token!]
348
- when :oauth then [Lexdrill::OauthRemote.spreadsheet_id, Lexdrill::GoogleAuth.ensure_token!]
348
+ kind = latest_remote_kind
349
+ spreadsheet_id = spreadsheet_id_for(kind)
350
+ return unless spreadsheet_id
351
+
352
+ [spreadsheet_id, kind == :remote ? Lexdrill::ServiceAccountAuth.fetch_token! : Lexdrill::GoogleAuth.ensure_token!]
353
+ end
354
+
355
+ def spreadsheet_id_for(kind)
356
+ case kind
357
+ when :remote then Lexdrill::Remote.spreadsheet_id
358
+ when :oauth then Lexdrill::OauthRemote.spreadsheet_id
349
359
  end
350
360
  end
351
361
 
@@ -360,6 +370,14 @@ class Lexdrill::CLI
360
370
 
361
371
  def newer?(path, other_path) = File.mtime(path) >= File.mtime(other_path)
362
372
 
373
+ def run_sheet
374
+ spreadsheet_id = spreadsheet_id_for(latest_remote_kind)
375
+ return print_no_remote unless spreadsheet_id
376
+
377
+ puts "https://docs.google.com/spreadsheets/d/#{spreadsheet_id}/edit"
378
+ 0
379
+ end
380
+
363
381
  def run_export
364
382
  sheet_name = argv[1]
365
383
  return print_export_usage unless sheet_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lexdrill
4
- VERSION = "0.16.0"
4
+ VERSION = "0.17.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lexdrill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siarhei Kisliak