datepick 1.0.0 → 1.1.1
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 +9 -2
- data/lib/datepick.rb +23 -6
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edc0a93673e9ac3916ec8e31ac1cbd6c886dd72699337fe077c5ee59911d3849
|
|
4
|
+
data.tar.gz: 4d2878ff16f75622a85461a5bef192a34ec9cafba94ef9fe59039879afce9467
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cea2c7637686272e5a39113b19f572c393a8fb33dbd007a69f4ad5aac26ed1aba36d17c53ad8b1b8697baf3faf055e9e71d940e1a7f23fb83db5649e5219dfff
|
|
7
|
+
data.tar.gz: 56f64ce009db0560b87eef26811dec8ac6f68e3c10761d4b392271d7108d658309db6c4243c3889ffb3ab5e44a2f834a14a109f7d120c561834cfc1b3eb9eca1
|
data/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Datepick - Interactive Terminal Date Picker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/rb/datepick)
|
|
4
|
+
[](https://www.ruby-lang.org/)
|
|
5
|
+
[](https://unlicense.org/)
|
|
6
|
+
[](https://github.com/isene/datepick/stargazers)
|
|
7
|
+
[](https://isene.org)
|
|
8
|
+
|
|
9
|
+
<img src="img/datepick_logo.svg" align="left" width="150" height="150"> A powerful, interactive terminal date picker built with Ruby and rcurses. Features vim-style navigation, configurable date formats, multiple month views, and extensive keyboard shortcuts. Perfect for shell scripts and command-line workflows that need date selection.
|
|
10
|
+
<br clear="left"/>
|
|
4
11
|
|
|
5
12
|
## Features
|
|
6
13
|
|
|
@@ -179,4 +186,4 @@ Created by [Geir Isene](https://isene.com/)
|
|
|
179
186
|
|
|
180
187
|
- **Homepage**: https://isene.com/
|
|
181
188
|
- **Source Code**: https://github.com/isene/datepick
|
|
182
|
-
- **RubyGems**: https://rubygems.org/gems/datepick
|
|
189
|
+
- **RubyGems**: https://rubygems.org/gems/datepick
|
data/lib/datepick.rb
CHANGED
|
@@ -41,8 +41,10 @@ class DatePicker
|
|
|
41
41
|
@current_month = Date.today
|
|
42
42
|
@config_mode = false
|
|
43
43
|
@config_selected = 0
|
|
44
|
-
@screen_w = `tput cols`.to_i
|
|
45
|
-
@screen_h = `tput lines`.to_i
|
|
44
|
+
@screen_w = (`tput cols`.to_i rescue 0)
|
|
45
|
+
@screen_h = (`tput lines`.to_i rescue 0)
|
|
46
|
+
@screen_w = 80 if @screen_w < 1
|
|
47
|
+
@screen_h = 24 if @screen_h < 1
|
|
46
48
|
|
|
47
49
|
# Initialize panes
|
|
48
50
|
@main_pane = Rcurses::Pane.new(1, 1, @screen_w, @screen_h - 4, nil, nil)
|
|
@@ -115,7 +117,7 @@ class DatePicker
|
|
|
115
117
|
@help_pane.refresh
|
|
116
118
|
|
|
117
119
|
# Update status
|
|
118
|
-
status_text = "Selected: #{@selected_date
|
|
120
|
+
status_text = "Selected: #{safe_strftime(@selected_date, @config['date_format'])}".fg(@config['colors']['selected'])
|
|
119
121
|
@status_pane.text = status_text
|
|
120
122
|
@status_pane.refresh
|
|
121
123
|
end
|
|
@@ -323,7 +325,7 @@ class DatePicker
|
|
|
323
325
|
@prev_content = "" # Force refresh
|
|
324
326
|
when 'ENTER'
|
|
325
327
|
Rcurses.cleanup!
|
|
326
|
-
puts @selected_date
|
|
328
|
+
puts safe_strftime(@selected_date, @config['date_format'])
|
|
327
329
|
exit
|
|
328
330
|
when 'LEFT', 'h', 'H'
|
|
329
331
|
@selected_date = @selected_date.prev_day
|
|
@@ -421,13 +423,22 @@ class DatePicker
|
|
|
421
423
|
def handle_config_edit
|
|
422
424
|
case @config_selected
|
|
423
425
|
when 0 # Date format
|
|
424
|
-
format_help = DATE_FORMATS.map { |k, v| "#{k}: #{Date.today
|
|
426
|
+
format_help = DATE_FORMATS.map { |k, v| "#{k}: #{safe_strftime(Date.today, v)}" }.join(" | ")
|
|
425
427
|
new_format = get_input_with_help("Date format", @config['date_format'], format_help)
|
|
426
428
|
# Check if user entered a number for quick format selection
|
|
427
429
|
if new_format && DATE_FORMATS[new_format]
|
|
428
430
|
@config['date_format'] = DATE_FORMATS[new_format]
|
|
429
431
|
elsif new_format && !new_format.empty?
|
|
430
|
-
|
|
432
|
+
# Validate the custom format string before accepting it
|
|
433
|
+
begin
|
|
434
|
+
result = Date.today.strftime(new_format)
|
|
435
|
+
# Must produce at least one digit (any useful date format does)
|
|
436
|
+
if result.match?(/\d/)
|
|
437
|
+
@config['date_format'] = new_format
|
|
438
|
+
end
|
|
439
|
+
rescue ArgumentError
|
|
440
|
+
# Invalid format string; keep the old one
|
|
441
|
+
end
|
|
431
442
|
end
|
|
432
443
|
@prev_content = "" # Force refresh to show new value
|
|
433
444
|
when 1 # Months before
|
|
@@ -495,6 +506,12 @@ class DatePicker
|
|
|
495
506
|
result.strip
|
|
496
507
|
end
|
|
497
508
|
|
|
509
|
+
def safe_strftime(date, fmt)
|
|
510
|
+
date.strftime(fmt)
|
|
511
|
+
rescue ArgumentError
|
|
512
|
+
date.strftime('%Y-%m-%d') + ' [invalid format]'
|
|
513
|
+
end
|
|
514
|
+
|
|
498
515
|
def update_current_month
|
|
499
516
|
@current_month = Date.new(@selected_date.year, @selected_date.month, 1)
|
|
500
517
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: datepick
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geir Isene
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rcurses
|
|
@@ -16,18 +16,18 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '6.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
27
|
-
description: A powerful interactive terminal date picker built with rcurses. Features
|
|
26
|
+
version: '6.0'
|
|
27
|
+
description: 'A powerful interactive terminal date picker built with rcurses. Features
|
|
28
28
|
vim-style navigation, configurable date formats, multiple month views, and extensive
|
|
29
29
|
keyboard shortcuts. Perfect for shell scripts and command-line workflows that need
|
|
30
|
-
date selection.
|
|
30
|
+
date selection. Version 1.1.1: Add date format validation and terminal size fallback.'
|
|
31
31
|
email: g@isene.com
|
|
32
32
|
executables:
|
|
33
33
|
- datepick
|