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 +4 -4
- data/README.md +1 -0
- data/lib/lexdrill/cli.rb +21 -3
- data/lib/lexdrill/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90fae028c5269ace52ee6fadc58941617f30b35a4d47f42c0654fcb88a478dd8
|
|
4
|
+
data.tar.gz: d1744556c29c18a5cf8f3b2ed8e23e2b4660bf3b0455bbde57abb1f29f954035
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
data/lib/lexdrill/version.rb
CHANGED