flycal-cli 0.7.2 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 371b44577d9ce6befe5b01bc54768999844615943b982a6e9cd9cd8c9737d007
4
- data.tar.gz: e3c6c00e03e38eccaea97ca045582a35d737916f1203963cc2c989ebf75de46b
3
+ metadata.gz: a9b15a5f08efcc922a2088d9a4c47fb852794932b4261406312f262905664c09
4
+ data.tar.gz: 114f71e6f2ca779315908015cf0b772f374b0e9de04e5775b220f8c3278aa5e5
5
5
  SHA512:
6
- metadata.gz: 35d47be3955556a98d3301782c2fc7deb7064134cb38792f128ade6c78807d5f28131696d14b3f2a72c7d7ae5acf9764b880d634ac52665accc6aa239c1026fe
7
- data.tar.gz: da10a2548c8bdd03ebc94e990b58e7a3d30de98e2f759a927e777e08d8617006713abeafd9e220fac4fbbb6d9c1e0835a8e0cb8650f4ae30f4a00a355bb1f478
6
+ metadata.gz: 1545a6259e5a710d4db52267909e7bbbff350aba2e75d617c9e6e2cbb722bb77f9663b5ca8e08483a5606f8030642952c7b1f5c170c4550de706503d15db3fd8
7
+ data.tar.gz: 6a63614ed3c9cd16ad5d1cf01b358e49edd5fc46ef285b986e181973ef0c660e9353f40e38ae130265bc470073730314d31fce48639ba3942338989a371042c5
data/README.md CHANGED
@@ -192,7 +192,7 @@ monday 3/8
192
192
  19 - 23
193
193
  ```
194
194
 
195
- If `pbcopy` is available (macOS), the slot list without the header is also copied to the clipboard.
195
+ If a clipboard tool is available (`pbcopy` on macOS, `wl-copy`/`xclip` on Linux, `clip` on Windows), the slot list without the header is also copied to the clipboard.
196
196
 
197
197
  Slot search windows are configured in `~/.flycal/config.yml`:
198
198
 
@@ -505,17 +505,11 @@ module FlycalCli
505
505
  end
506
506
 
507
507
  def copy_slots_to_clipboard(text)
508
- return unless pbcopy_available?
508
+ tool = Clipboard.copy(SlotFormatter.strip_ansi(text))
509
+ return unless tool
509
510
 
510
- IO.popen("pbcopy", "w") { |io| io.write(SlotFormatter.strip_ansi(text)) }
511
511
  puts ""
512
- puts Locale.t("slots.copied_to_clipboard")
513
- rescue StandardError
514
- nil
515
- end
516
-
517
- def pbcopy_available?
518
- system("which", "pbcopy", out: File::NULL, err: File::NULL)
512
+ puts Locale.t("slots.copied_to_clipboard", tool: tool)
519
513
  end
520
514
 
521
515
  def parse_hour_minute(value)
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FlycalCli
4
+ # Cross-platform clipboard helper.
5
+ # Prefers: pbcopy (macOS) → wl-copy (Wayland) → xclip (X11) → clip (Windows).
6
+ module Clipboard
7
+ module_function
8
+
9
+ TOOLS = [
10
+ { name: :pbcopy, command: %w[pbcopy] },
11
+ { name: :wl_copy, command: %w[wl-copy] },
12
+ { name: :xclip, command: %w[xclip -selection clipboard] },
13
+ { name: :clip, command: %w[clip] }
14
+ ].freeze
15
+
16
+ def copy(text)
17
+ tool = available_tool
18
+ return nil unless tool
19
+
20
+ IO.popen(tool[:command], "w") { |io| io.write(text.to_s) }
21
+ return nil unless $?.success?
22
+
23
+ tool[:name].to_s
24
+ rescue StandardError
25
+ nil
26
+ end
27
+
28
+ def available?
29
+ !available_tool.nil?
30
+ end
31
+
32
+ def available_tool
33
+ TOOLS.find { |tool| command_exists?(tool[:command].first) }
34
+ end
35
+
36
+ def command_exists?(name)
37
+ exts =
38
+ if Gem.win_platform?
39
+ ENV.fetch("PATHEXT", ".EXE;.BAT;.CMD").split(";").reject(&:empty?)
40
+ else
41
+ [""]
42
+ end
43
+
44
+ ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).any? do |dir|
45
+ next false if dir.to_s.empty?
46
+
47
+ exts.any? do |ext|
48
+ path = File.join(dir, "#{name}#{ext}")
49
+ File.file?(path) && File.executable?(path)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FlycalCli
4
- VERSION = '0.7.2'
4
+ VERSION = '0.7.3'
5
5
  end
data/lib/flycal_cli.rb CHANGED
@@ -6,6 +6,7 @@ require "flycal_cli/locale"
6
6
  require "flycal_cli/auth"
7
7
  require "flycal_cli/duration_parser"
8
8
  require "flycal_cli/date_time_parser"
9
+ require "flycal_cli/clipboard"
9
10
  require "flycal_cli/calendar_service"
10
11
  require "flycal_cli/slot_finder"
11
12
  require "flycal_cli/slot_formatter"
data/locales/en.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "no_available": "No available slots found.",
33
33
  "no_calendar": "No calendar found. Run 'flycal config' to set a default.",
34
34
  "header": "found %{count} slots\nfrom %{from} to %{to}\nwith duration %{duration}, template %{template}\nconsidering calendars",
35
- "copied_to_clipboard": "✓ Slot list copied to clipboard (pbcopy)"
35
+ "copied_to_clipboard": "✓ Slot list copied to clipboard (%{tool})"
36
36
  },
37
37
  "errors": {
38
38
  "not_connected": "You are not connected. Run 'flycal login' first.",
data/locales/it.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "no_available": "Nessuno slot disponibile.",
33
33
  "no_calendar": "Nessun calendario trovato. Esegui 'flycal config' per impostare il predefinito.",
34
34
  "header": "trovati %{count} slot\nda %{from} a %{to}\ncon durata %{duration}, template %{template}\nconsiderando i calendari",
35
- "copied_to_clipboard": "✓ Lista slot copiata negli appunti (pbcopy)"
35
+ "copied_to_clipboard": "✓ Lista slot copiata negli appunti (%{tool})"
36
36
  },
37
37
  "errors": {
38
38
  "not_connected": "Non sei connesso. Esegui prima 'flycal login'.",
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: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - flycal-cli
@@ -138,6 +138,7 @@ files:
138
138
  - lib/flycal_cli/auth.rb
139
139
  - lib/flycal_cli/calendar_service.rb
140
140
  - lib/flycal_cli/cli.rb
141
+ - lib/flycal_cli/clipboard.rb
141
142
  - lib/flycal_cli/config.rb
142
143
  - lib/flycal_cli/date_time_parser.rb
143
144
  - lib/flycal_cli/duration_parser.rb