rbnotes 0.4.16 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3f023516dcf1e39f18c6cd0195a548debfd635e23d476bdb7e89a6ddc5f981e
4
- data.tar.gz: 52507a17c873c8732922e1cc5990fa41d74f36fca1f558fa5440090f3fcd9fe2
3
+ metadata.gz: 65aec23d03fa8672d8aada42a39d6d0f97643ca3481050926ae11aa2a05dc433
4
+ data.tar.gz: c28a9209d1374f351a87e0a0a696312bdc37f70b2d55c97e5e2920703c83643b
5
5
  SHA512:
6
- metadata.gz: '0946450a7eeda50688cc5dc836ce30e86d5db28e2af8dca8e84805026648ba018116e98d5b3d316339960a0273d1e717178c4832932418440e0db3c1d1b4e9a9'
7
- data.tar.gz: 125c3c6fa116fc5cf13d82ba6fb522972b82364b61002de2adc6d36ab1f6d77051f89a948a7cc9ec28acce8179399b040bfc4d983e1c83c65bb2548cc44ee8eb
6
+ metadata.gz: 285b05aee90d97dcf11fca4d753e2265ae11253d504e9a787b34f4d64a74e47486cd6a127d652f6f746b934f90c6c699342ea8621b13ef06da2816ef3f91eb98
7
+ data.tar.gz: 581f9192f023a4a50f43ea475b72aa5a145c054520c6b25f9a59c2f758f980c81259df788c34c47c08b7a901b55f6f77ae60e39de0e5e230727d990fcd9f54d3
data/CHANGELOG.md CHANGED
@@ -5,19 +5,42 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
- - Nothing to record here.
8
+ - nothing to record here.
9
+
10
+ ## [0.4.17] - 2021-04-21
11
+ ### Added
12
+ - Change for the `show` command to accept keywords. (#84)
13
+ - Add `-r` option to the `show` command. (#110)
14
+ - which specifies to enable "raw" output mode.
15
+
16
+ ### Fixed
17
+ - Update the help text for the `list` command. (#112, #113)
18
+ - Remove trailing spaces. (#108)
19
+ - Fix minor bugs:
20
+ - remove redundant use of an instance variable,
21
+ - change the behavior to exit when no notes found in the repo,
22
+ - `pick` and `show`
23
+ - change delimiter line size according to terminal column.
24
+ - `show`
9
25
 
10
26
  ## [0.4.16] - 2021-04-17
27
+ ### Added
11
28
  - Add a new configuration setting to change the default behavior of
12
29
  the `list` (and `pick`) command. (#109)
13
30
 
14
31
  ## [0.4.15] - 2021-04-15
32
+ ### Added
15
33
  - Enable to use delimiters within a timestamp string. (#104)
34
+
35
+ ### Fixed
16
36
  - Fix issue #105: `list` ignores the 2nd arg when specified `-w`
17
37
  option.
18
38
 
19
39
  ## [0.4.14] - 2021-04-10
40
+ ### Added
20
41
  - Add `-n` option to `show` command. (#102)
42
+
43
+ ### Fixed
21
44
  - Fix issue #100: modify to catch Textrepo::MissingTimestampError.
22
45
 
23
46
  ## [0.4.13] - 2021-03-30
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbnotes (0.4.16)
4
+ rbnotes (0.4.17)
5
5
  textrepo (~> 0.5.8)
6
6
  unicode-display_width (~> 1.7)
7
7
 
data/exe/rbnotes CHANGED
@@ -21,7 +21,7 @@ class App
21
21
  file = args.shift
22
22
  raise ArgumentError, args.unshift(arg) if file.nil?
23
23
  file = File.expand_path(file)
24
- raise ArgumentError, "no such file: %s" % file unless FileTest.exist?(file)
24
+ raise ArgumentError, "no such file: %s" % file unless FileTest.exist?(file)
25
25
  @gopts[:conf_file] = file
26
26
  when "-v", "--version"
27
27
  args.clear
@@ -192,7 +192,7 @@ string could be used as an argument of some rbnotes commands, such
192
192
  "2020-11-06" -> "20201106000000"
193
193
  "20201106" -> "20201106000000"
194
194
  "2020-11-06 16" -> "20201106160000"
195
- "2020-11-06 16:51" -> "20201106165100"
195
+ "2020-11-06 16:51" -> "20201106165100"
196
196
  STAMP
197
197
  end
198
198
  end
@@ -18,7 +18,8 @@ module Rbnotes::Commands
18
18
  # timestamp pattern or a keyword.
19
19
  #
20
20
  # Any order of timestamp patterns and keywords mixture is
21
- # acceptable. The redundant patterns are just ignored.
21
+ # acceptable. The redundant patterns or invalid patterns are just
22
+ # ignored.
22
23
  #
23
24
  # A timestamp pattern is a string which would match several
24
25
  # Timestamp objects. A timestamp is an instance of
@@ -58,7 +59,7 @@ module Rbnotes::Commands
58
59
  @opts = {}
59
60
  parse_opts(args)
60
61
 
61
- if args.empty?
62
+ if args.empty? and !@opts[:enum_week]
62
63
  default_behavior = conf[:list_default] || DEFAULT_BEHAVIOR
63
64
  args << default_behavior
64
65
  end
@@ -66,22 +67,21 @@ module Rbnotes::Commands
66
67
  utils = Rbnotes.utils
67
68
  patterns = utils.read_timestamp_patterns(args, enum_week: @opts[:enum_week])
68
69
 
69
- @repo = Textrepo.init(conf)
70
- notes = utils.find_notes(patterns, @repo)
70
+ repo = Textrepo.init(conf)
71
+ stamps = utils.find_notes(patterns, repo)
71
72
  output = []
72
73
  if @opts[:verbose]
73
- collect_timestamps_by_date(notes).each { |date, timestamps|
74
+ collect_timestamps_by_date(stamps).each { |date, timestamps|
74
75
  output << "#{date} (#{timestamps.size})"
75
76
  timestamps.each { |timestamp|
76
77
  pad = " "
77
78
  output << utils.make_headline(timestamp,
78
- @repo.read(timestamp), pad)
79
+ repo.read(timestamp), pad)
79
80
  }
80
81
  }
81
82
  else
82
- notes.each { |timestamp|
83
- output << utils.make_headline(timestamp,
84
- @repo.read(timestamp))
83
+ stamps.each { |timestamp|
84
+ output << utils.make_headline(timestamp, repo.read(timestamp))
85
85
  }
86
86
  end
87
87
  puts output
@@ -90,13 +90,17 @@ module Rbnotes::Commands
90
90
  def help # :nodoc:
91
91
  puts <<HELP
92
92
  usage:
93
- #{Rbnotes::NAME} list [-w|--week][STAMP_PATTERN|KEYWORD]
93
+ #{Rbnotes::NAME} list [OPTIONS] [STAMP_PATTERN|KEYWORD]
94
94
 
95
95
  Show a list of notes. When no arguments, make a list with all notes
96
96
  in the repository. When specified STAMP_PATTERN, only those match the
97
97
  pattern are listed. Instead of STAMP_PATTERN, some KEYWORDs could be
98
98
  used.
99
99
 
100
+ OPTIONS:
101
+ -v, --verbose
102
+ -w, --week
103
+
100
104
  STAMP_PATTERN must be:
101
105
 
102
106
  (a) full qualified timestamp (with suffix): "20201030160200"
@@ -114,6 +118,24 @@ KEYWORD:
114
118
  - "this_month" (or "tm")
115
119
  - "last_month" (or "lm")
116
120
 
121
+ An option "--verbose" is acceptable. It specifies to counts number of
122
+ notes by each day, then put it with the date before notes. It looks
123
+ like as follows:
124
+
125
+ 2021-04-19 (3)
126
+ 20210419134222: Foo
127
+ 20210419120235: Bar
128
+ 20210419110057: Baz
129
+ 2021-04-18 (1)
130
+ 20210418125353: Hoge
131
+ :
132
+
133
+ When no STAMP_PATTERN or KEYWORD was specified, the behavior of this
134
+ command could be specified with a configuration setting,
135
+ ":list_default:". The value must be one of valid keywords. If no
136
+ settings was also given, this command would behave like "today" was
137
+ specified as the setting.
138
+
117
139
  An option "--week" is also acceptable. It specifies to enumerate all
118
140
  days of a week. Typically, the option is used with a STAMP_PATTERN
119
141
  which specifies a date, such "20201117", then it enumerates all days
@@ -23,11 +23,14 @@ module Rbnotes::Commands
23
23
  utils = Rbnotes.utils
24
24
  patterns = utils.read_timestamp_patterns(args, enum_week: @opts[:enum_week])
25
25
 
26
- @repo = Textrepo.init(conf)
26
+ repo = Textrepo.init(conf)
27
+
28
+ stamps = utils.find_notes(patterns, repo)
29
+ return if stamps.empty?
27
30
 
28
31
  list = []
29
- utils.find_notes(patterns, @repo).each { |timestamp|
30
- list << utils.make_headline(timestamp, @repo.read(timestamp))
32
+ stamps.each { |timestamp|
33
+ list << utils.make_headline(timestamp, repo.read(timestamp))
31
34
  }
32
35
 
33
36
  picker = conf[:picker]
@@ -1,18 +1,13 @@
1
1
  module Rbnotes::Commands
2
2
 
3
3
  ##
4
- # Shows the content of the notes specified by arguments. Each
5
- # argument must be a string which can be converted into
6
- # Textrepo::Timestamp object.
4
+ # Shows the content of the notes specified by arguments. Arguments
5
+ # should be timestamp patterns or keywords. See the document for
6
+ # the `list` command to know about such arguments.
7
7
  #
8
8
  # Accepts an option with `-n NUMBER` (or `--num-of-lines`), to show
9
9
  # the first NUMBER lines of the content of each note.
10
10
  #
11
- # A string for Textrepo::Timestamp must be:
12
- #
13
- # "20201106112600" : year, date, time and sec
14
- # "20201106112600_012" : with suffix
15
- #
16
11
  # If no argument is passed, reads the standard input for arguments.
17
12
  # If a specified timestamp does not exist in the repository as a key,
18
13
  # Rbnotes::MissingTimestampError will occur.
@@ -26,8 +21,9 @@ module Rbnotes::Commands
26
21
  @opts = {}
27
22
  parse_opts(args)
28
23
 
29
- stamps = Rbnotes.utils.read_multiple_timestamps(args)
30
24
  repo = Textrepo.init(conf)
25
+ stamps = read_timestamps(args, repo)
26
+ return if stamps.empty?
31
27
 
32
28
  content = stamps.map { |stamp|
33
29
  begin
@@ -45,7 +41,7 @@ module Rbnotes::Commands
45
41
  }.to_h
46
42
 
47
43
  pager = conf[:pager]
48
- unless pager.nil?
44
+ unless pager.nil? or @opts[:raw]
49
45
  puts_with_pager(pager, make_output(content))
50
46
  else
51
47
  puts make_output(content)
@@ -55,14 +51,23 @@ module Rbnotes::Commands
55
51
  def help # :nodoc:
56
52
  puts <<HELP
57
53
  usage:
58
- #{Rbnotes::NAME} show [(-n|--num-of-lines) NUMBER] [TIMESTAMP...]
54
+ #{Rbnotes::NAME} show [OPTIONS] [STAMP_PATTERN|KEYWORD...]
59
55
 
60
- Show the content of given notes. TIMESTAMP must be a fully qualified
61
- one, such "20201016165130" or "20201016165130_012" if it has a suffix.
56
+ Show the content of given notes. It accepts timestamp patterns and
57
+ keywords like the `list` (or `pick`) command. See the help for the
58
+ `list` command to know more about stamp patterns and keywords.
59
+
60
+ OPTIONS:
61
+ -n, --num-of-lines NUMBER
62
+ -r, --raw
62
63
 
63
64
  Accept an option with `-n NUMBER` (or `--num-of-lines`), to show the
64
65
  first NUMBER lines of the content of each note.
65
66
 
67
+ Also accepts `-r` (or `--raw`) option to specify to use "raw" output,
68
+ which means no use any pager, no apply to any process to make output.
69
+ The behavior is intended to be used within a pipeline.
70
+
66
71
  The command try to read its argument from the standard input when no
67
72
  argument was passed in the command line.
68
73
  HELP
@@ -84,6 +89,8 @@ HELP
84
89
  raise ArgumentError, "illegal number (must be greater than 0): %d" % num_of_lines unless num_of_lines > 0
85
90
 
86
91
  @opts[:num_of_lines] = num_of_lines
92
+ when "-r", "--raw"
93
+ @opts[:raw] = true
87
94
  else
88
95
  args.unshift(arg)
89
96
  break
@@ -91,6 +98,17 @@ HELP
91
98
  end
92
99
  end
93
100
 
101
+ def read_timestamps(args, repo)
102
+ utils = Rbnotes.utils
103
+ if args.empty?
104
+ stamps = utils.read_multiple_timestamps(args)
105
+ else
106
+ patterns = utils.read_timestamp_patterns(args)
107
+ stamps = utils.find_notes(patterns, repo)
108
+ end
109
+ stamps
110
+ end
111
+
94
112
  def puts_with_pager(pager, output)
95
113
  require "open3"
96
114
  Open3.pipeline_w(pager) { |stdin|
@@ -108,7 +126,7 @@ HELP
108
126
 
109
127
  _, column = IO.console_size
110
128
  output = content.map { |timestamp, text|
111
- ary = [make_heading(timestamp, [column, 72].min)]
129
+ ary = [make_heading(timestamp, column - 10)]
112
130
  ary.concat(text)
113
131
  ary
114
132
  }
data/lib/rbnotes/utils.rb CHANGED
@@ -165,6 +165,7 @@ module Rbnotes
165
165
  def read_timestamp_patterns(args, enum_week: false)
166
166
  patterns = nil
167
167
  if enum_week
168
+ args.unshift(Time.now.strftime("%Y%m%d")) if args.size == 0
168
169
  patterns = []
169
170
  while args.size > 0
170
171
  arg = args.shift
@@ -1,4 +1,4 @@
1
1
  module Rbnotes
2
- VERSION = "0.4.16"
3
- RELEASE = "2021-04-17"
2
+ VERSION = "0.4.17"
3
+ RELEASE = "2021-04-21"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - mnbi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-17 00:00:00.000000000 Z
11
+ date: 2021-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: textrepo