flycal-cli 1.2.2 → 1.3
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/lib/flycal/cli/app.rb +4 -2
- data/lib/flycal/cli/hooks.rb +78 -0
- data/lib/flycal/cli.rb +1 -0
- data/lib/flycal.rb +1 -1
- data/lib/rubygems_plugin.rb +13 -0
- data/locales/en.json +11 -0
- data/locales/it.json +11 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a7c1e482dd1e5df5126ae7a23f5c43032268c94c1cdf6dcc22e4b145e609be7
|
|
4
|
+
data.tar.gz: d0d6caf44d2348e66fb53969b5e912fe614a77bfc5a449b31297deb3665eb10d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc16924f3ef92c7824e939900334c09292154690b535dd14fd3296a9f7a9a42e2f4f050a637a93fd4f63575986936322bcc27092ec019c3e5ec579a233f95486
|
|
7
|
+
data.tar.gz: 503012381ef20c95d61b8ca80e0472b93a2715af38a3af5c683cd4a060d12050aebedcf9d6f4b1527bce9a9d5a523526e5e3d4f41c150f27262de14ee72bd1f8
|
data/lib/flycal/cli/app.rb
CHANGED
|
@@ -29,7 +29,8 @@ module Cli
|
|
|
29
29
|
apply_locale_override
|
|
30
30
|
if Auth.logged_in?
|
|
31
31
|
puts Locale.t("login.already_connected")
|
|
32
|
-
|
|
32
|
+
Hooks.after_login
|
|
33
|
+
puts "\n#{Locale.t('login.next_config')}" unless Config.calendar_default
|
|
33
34
|
return
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -39,7 +40,8 @@ module Cli
|
|
|
39
40
|
begin
|
|
40
41
|
Auth.login(mode)
|
|
41
42
|
puts "\n#{Locale.t('login.success')}"
|
|
42
|
-
|
|
43
|
+
Hooks.after_login
|
|
44
|
+
puts "\n#{Locale.t('login.next_config')}" unless Config.calendar_default
|
|
43
45
|
rescue Flycal::Error => e
|
|
44
46
|
puts "Error: #{e.message}"
|
|
45
47
|
exit 1
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flycal
|
|
4
|
+
module Cli
|
|
5
|
+
# Post-install / post-login onboarding.
|
|
6
|
+
class Hooks
|
|
7
|
+
class << self
|
|
8
|
+
def after_install
|
|
9
|
+
return if skip_post_install?
|
|
10
|
+
return unless interactive?
|
|
11
|
+
|
|
12
|
+
if Auth.logged_in?
|
|
13
|
+
after_login
|
|
14
|
+
return
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
puts "#{bold('flycal-cli')} #{Locale.t('hooks.after_install.ready')}"
|
|
18
|
+
print "#{Locale.t('hooks.after_install.prompt')} "
|
|
19
|
+
return unless accept_default_yes?
|
|
20
|
+
|
|
21
|
+
launch_login
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def after_login
|
|
25
|
+
return unless Auth.logged_in?
|
|
26
|
+
return if Config.calendar_default
|
|
27
|
+
|
|
28
|
+
calendars = Flycal.connect(credentials: Auth.credentials).list_calendars
|
|
29
|
+
primary = calendars.find { |calendar| calendar.respond_to?(:primary) && calendar.primary } || calendars.first
|
|
30
|
+
return unless primary
|
|
31
|
+
|
|
32
|
+
Config.calendar_default = primary.id
|
|
33
|
+
name = primary.summary.to_s.strip
|
|
34
|
+
name = primary.id if name.empty?
|
|
35
|
+
|
|
36
|
+
puts "#{bold('flycal-cli')} #{Locale.t('hooks.after_login.using', { calendar: bold(name) })}"
|
|
37
|
+
puts Locale.t("hooks.after_login.change")
|
|
38
|
+
puts Locale.t("hooks.after_login.goodbye")
|
|
39
|
+
rescue StandardError
|
|
40
|
+
nil
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def launch_login
|
|
44
|
+
bin = begin
|
|
45
|
+
Gem.bin_path("flycal-cli", "flycal")
|
|
46
|
+
rescue Gem::Exception
|
|
47
|
+
"flycal"
|
|
48
|
+
end
|
|
49
|
+
system(bin, "login")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def skip_post_install?
|
|
53
|
+
ENV["FLYCAL_SKIP_POST_INSTALL"].to_s == "1"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def interactive?
|
|
57
|
+
$stdin.tty? && $stdout.tty?
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def accept_default_yes?(input = $stdin)
|
|
61
|
+
line = input.gets
|
|
62
|
+
return true if line.nil?
|
|
63
|
+
|
|
64
|
+
answer = line.strip.downcase
|
|
65
|
+
return true if answer.empty?
|
|
66
|
+
|
|
67
|
+
%w[y yes].include?(answer)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def bold(text)
|
|
71
|
+
return text.to_s unless $stdout.tty?
|
|
72
|
+
|
|
73
|
+
"\e[1m#{text}\e[0m"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/lib/flycal/cli.rb
CHANGED
data/lib/flycal.rb
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Loaded automatically by RubyGems. Keep this file tiny; work happens in the hook.
|
|
4
|
+
Gem.post_install do |installer|
|
|
5
|
+
next unless installer.spec.name == "flycal-cli"
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
require "flycal_cli"
|
|
9
|
+
Flycal::Cli::Hooks.after_install
|
|
10
|
+
rescue LoadError, StandardError => e
|
|
11
|
+
warn "flycal-cli post-install: #{e.message}"
|
|
12
|
+
end
|
|
13
|
+
end
|
data/locales/en.json
CHANGED
|
@@ -52,6 +52,17 @@
|
|
|
52
52
|
"header": "found %{count} slots\nfrom %{from} to %{to}\nwith duration %{duration}, template %{template}\nconsidering calendars",
|
|
53
53
|
"copied_to_clipboard": "✓ Slot list copied to clipboard (%{tool})"
|
|
54
54
|
},
|
|
55
|
+
"hooks": {
|
|
56
|
+
"after_install": {
|
|
57
|
+
"ready": "is setup correctly,",
|
|
58
|
+
"prompt": "Let's login w/ Google to start using it (Y/n):"
|
|
59
|
+
},
|
|
60
|
+
"after_login": {
|
|
61
|
+
"using": "is using %{calendar} by default,",
|
|
62
|
+
"change": "you can change it using command 'flycal config',",
|
|
63
|
+
"goodbye": "happy calendling!"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
55
66
|
"errors": {
|
|
56
67
|
"not_connected": "You are not connected. Run 'flycal login' first.",
|
|
57
68
|
"duration_positive": "Error: --in must be a positive duration.",
|
data/locales/it.json
CHANGED
|
@@ -52,6 +52,17 @@
|
|
|
52
52
|
"header": "trovati %{count} slot\nda %{from} a %{to}\ncon durata %{duration}, template %{template}\nconsiderando i calendari",
|
|
53
53
|
"copied_to_clipboard": "✓ Lista slot copiata negli appunti (%{tool})"
|
|
54
54
|
},
|
|
55
|
+
"hooks": {
|
|
56
|
+
"after_install": {
|
|
57
|
+
"ready": "è installato correttamente,",
|
|
58
|
+
"prompt": "Accedi con Google per iniziare a usarlo (Y/n):"
|
|
59
|
+
},
|
|
60
|
+
"after_login": {
|
|
61
|
+
"using": "sta usando %{calendar} come predefinito,",
|
|
62
|
+
"change": "puoi cambiarlo con il comando 'flycal config',",
|
|
63
|
+
"goodbye": "happy calendling!"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
55
66
|
"errors": {
|
|
56
67
|
"not_connected": "Non sei connesso. Esegui prima 'flycal login'.",
|
|
57
68
|
"duration_positive": "Errore: --in deve essere una durata positiva.",
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flycal-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: '1.3'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- flycal-cli
|
|
@@ -146,6 +146,7 @@ files:
|
|
|
146
146
|
- lib/flycal/cli/clipboard.rb
|
|
147
147
|
- lib/flycal/cli/config.rb
|
|
148
148
|
- lib/flycal/cli/file_cache.rb
|
|
149
|
+
- lib/flycal/cli/hooks.rb
|
|
149
150
|
- lib/flycal/cli/locale.rb
|
|
150
151
|
- lib/flycal/client.rb
|
|
151
152
|
- lib/flycal/credentials.rb
|
|
@@ -176,6 +177,7 @@ files:
|
|
|
176
177
|
- lib/flycal/time_format.rb
|
|
177
178
|
- lib/flycal/version.rb
|
|
178
179
|
- lib/flycal_cli.rb
|
|
180
|
+
- lib/rubygems_plugin.rb
|
|
179
181
|
- locales/en.json
|
|
180
182
|
- locales/it.json
|
|
181
183
|
- mcp/README.md
|