todo_cli_app 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f719e4ece6562acbae21e4b49ad0ccd745cbb22d677d4c93d67235a6abe6258d
4
- data.tar.gz: 2e8a792cc93450fe14a8114e7296d4a556562334352966b4c67000f75351caab
3
+ metadata.gz: c1c83918a499fec38e8dd67bc720beef4db1617735123dd42461a14752ef82fa
4
+ data.tar.gz: e188b50840d954bf8f73fb56b47ba168169ce4391f9cb7095a06a3dc95517e51
5
5
  SHA512:
6
- metadata.gz: 0a60969051029059dcd7b5e8cc093cafd5673976ae2c29dbc331d8b31746503de3e88a4c335664beb754b06abd4e3f659c7d26520d6ade21b5291bbf84b21af0
7
- data.tar.gz: 30b8b0d901f123de5394f3c3f8dfe4a5344eb56e242f22228dd8a5e650d56896c31a085ecaec0213dfd539e86429d9a900faf22e73b87a3213359d1f5b54a7fa
6
+ metadata.gz: 20c39dca88b36af7f9a55b669845687cd39cc923d1db358bdd1350fcd28334193a68b6fed8b1b8f757357913f40705d9b56a1941bdba5b6b8d7788b3f0f18d2b
7
+ data.tar.gz: ee1bf6cd45ae023127e6625ba0164745c49e638c8158d6a115c4653b9dee00c8932245aff759acec08fd249e1aa1417772f1714f6dffcbbd0191dacf89466225
@@ -17,6 +17,10 @@ module ToDo
17
17
  File.join(Dir.home, DIR_PATH)
18
18
  end
19
19
 
20
+ def editor
21
+ options.editor || '$EDITOR'
22
+ end
23
+
20
24
  def file_name
21
25
  "#{options.date}.md"
22
26
  end
@@ -5,7 +5,7 @@ module ToDo
5
5
  # OptionParser wrapper for the to-do app.
6
6
  #
7
7
  class Parser
8
- Options = Struct.new(:date, :yesterday, :tomorrow, :query, :visualize, keyword_init: true)
8
+ Options = Struct.new(:date, :editor, :yesterday, :tomorrow, :query, :visualize, keyword_init: true)
9
9
 
10
10
  attr_reader :args
11
11
 
@@ -19,6 +19,7 @@ module ToDo
19
19
  A ruby CLI-only To Do app, because why not?
20
20
  Usage:
21
21
  todo -d, --date 2020-12-25 # Open todo for the date
22
+ todo -e, --editor code # Uses code as the editor. Default is $EDITOR.
22
23
  todo -y, --yesterday # Open todo yesterday
23
24
  todo -t, --tomorrow # Open todo for tomorrow
24
25
  todo # Open todo for today
@@ -41,6 +42,10 @@ module ToDo
41
42
  options.date = parse_date(d)
42
43
  end
43
44
 
45
+ parser.on('-eEDITOR', '--editor=EDITOR', 'Editor command') do |e|
46
+ options.editor = e
47
+ end
48
+
44
49
  parser.on('-fQUERY', '--find=QUERY', 'Looks for query') do |q|
45
50
  options.query = q
46
51
  end
@@ -28,11 +28,18 @@ module ToDo
28
28
  end
29
29
 
30
30
  def start
31
- system("$EDITOR #{context.file_path}")
31
+ exit_and_set_editor unless system("command -v #{context.editor}", out: ['/dev/null'])
32
+ system("#{context.editor} #{context.file_path}")
32
33
  end
33
34
 
34
35
  private
35
36
 
37
+ def exit_and_set_editor
38
+ puts "#{context.editor} not found" if context.editor
39
+ puts "Please set an editor to use with `todo -e EDITOR'. Check `todo -h' for more info."
40
+ exit 1
41
+ end
42
+
36
43
  def prepare_todo_file
37
44
  return if Dir[context.file_path].any?
38
45
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ToDo
4
4
  MAJOR = 0
5
- MINOR = 2
5
+ MINOR = 3
6
6
  PATCH = 0
7
7
  VERSION = [MAJOR, MINOR, PATCH].join('.')
8
8
  end
@@ -19,6 +19,7 @@ module ToDo
19
19
  end
20
20
 
21
21
  def view
22
+ exit_and_install_pandoc unless system('command -v pandoc', out: ['/dev/null'])
22
23
  raise 'Something failed with Pandoc' unless system(command)
23
24
 
24
25
  update_body_class
@@ -38,6 +39,11 @@ module ToDo
38
39
  ].join(' ')
39
40
  end
40
41
 
42
+ def exit_and_install_pandoc
43
+ puts 'Please install pandoc first. https://pandoc.org/installing.html'
44
+ exit 1
45
+ end
46
+
41
47
  def tmpfile
42
48
  "#{File.join(Dir.tmpdir, context.file_name)}.html"
43
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todo_cli_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Manuel Ramallo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-28 00:00:00.000000000 Z
11
+ date: 2020-12-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A to-do app, the ruby cli-only edition to-do app [insert registered mark
14
14
  logo here].