til-rb 0.0.4 → 0.0.5

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/til +16 -1
  3. data/lib/til/core.rb +5 -4
  4. data/lib/til/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7663677e1c231cfb2bbba240e889b85ac2ae1c22519b0c365fa225e91ed876f9
4
- data.tar.gz: 5404592be317f806bec787e4f21a444ddbb22e2fe680b1278b93ad8c0b3bff72
3
+ metadata.gz: 6f0027d094b71d1fa0d6f5e44cba6156437c0f9dea43db6975e4dae481d71836
4
+ data.tar.gz: 60d850a49f82d03580d8bcba303ee7a7fdf9dd099037c17947bdc86f19163ee0
5
5
  SHA512:
6
- metadata.gz: 1b98afb9724d5818dc13d5dc0d59cc3b1ceeed17e6b111f09d00159eb2dc943b4649c59009bb815a86c1fb82e833eff16d00630d2abd35a101ed815da9b736a4
7
- data.tar.gz: 7c5ccdb8864eefe7b7242a066b7d517cfe966e52fa610d95f85f7dfb546b7f97c2575d0eb7e75cde810d3ef1d7e3948def5f1bf370d9cee741d833995a28d63a
6
+ metadata.gz: ea9f23f36f457bdbb0c75dfb8bdb3040ea2b77e65d29c7bf046aa7b94b45ac525d64984c3c2f74a02f794a60161d56baeab2143913a4865b4b2cb112da10e163
7
+ data.tar.gz: 1a0dc250f4939160acf604d1869cef37325427c155510c44ace0c1a335a331c8945d0d9b8ebe34334d310a1e4bd147662fdb5ccbec65c741ec32fcabb903b6dc
data/bin/til CHANGED
@@ -1,5 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'til-rb'
4
+ require 'optparse'
4
5
 
5
- Til::Core.run
6
+ options = {}
7
+ OptionParser.new do |opts|
8
+ opts.banner = 'Usage: til [options]'
9
+
10
+ opts.on('-tTITLE', '--titleTITLE', 'Set the title from the command line') do |title|
11
+ options[:title] = title
12
+ end
13
+
14
+ opts.on('-h', '--help', 'Prints this help') do
15
+ puts opts
16
+ exit
17
+ end
18
+ end.parse!
19
+
20
+ Til::Core.run options: options
@@ -5,7 +5,7 @@ require 'readline'
5
5
  module Til
6
6
  class Core
7
7
 
8
- def self.run
8
+ def self.run(options: {})
9
9
  # Exit if `fzf` is not available
10
10
  # Optionally print a spinner
11
11
  # Grab the list of existing categories
@@ -18,11 +18,12 @@ module Til
18
18
  # Create the new file
19
19
  # Create a new commit
20
20
  # Output a link to the file and the link to edit it
21
- til = new
21
+ til = new(options: options)
22
22
  til.run
23
23
  end
24
24
 
25
- def initialize(kernel: Kernel, process: Process, env: ENV, github_client: nil, stderr: $stderr)
25
+ def initialize(options: {}, kernel: Kernel, process: Process, env: ENV, github_client: nil, stderr: $stderr)
26
+ @options = options
26
27
  @kernel = kernel
27
28
  @process = process
28
29
  @env = env
@@ -41,7 +42,7 @@ module Til
41
42
  if @new_category
42
43
  selected_category = prompt_for_new_category
43
44
  end
44
- prepopulate_tempfile(selected_category)
45
+ prepopulate_tempfile(selected_category, @options[:title])
45
46
  open_editor
46
47
  til_content = read_file
47
48
  commit_new_til(selected_category, til_content)
@@ -1,5 +1,5 @@
1
1
  module Til
2
2
 
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: til-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Jambet