til_cli 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/til.rb +11 -12
- data/lib/til/directory.rb +2 -2
- data/lib/til/initializer.rb +6 -3
- data/lib/til/settings.rb +1 -1
- data/lib/til/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 219d074e0bd606858cd008f6524db4a64646a4bb
|
4
|
+
data.tar.gz: 6fe01b25f7acecace8c85ca0c9e4ad541beb4cde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db05e1a5be6541a85e3bd558aac099eee84df76585c23b404cbd44e2428be74d12884f68b466837373b1de45846cbc355431a2395a32d9d44caa3f9dc23937b0
|
7
|
+
data.tar.gz: 97f119ee3338e1508d72ee871a46dea63003ba89ff19ab6d83b06ffcdfba9bc75a02481de25ca287be8da31e79afa704b0e6ffe7d21988cdffc3bde8c2f9fed3
|
data/lib/til.rb
CHANGED
@@ -10,8 +10,6 @@ require 'til/note_deleter'
|
|
10
10
|
require 'til/initializer'
|
11
11
|
|
12
12
|
module Til
|
13
|
-
DIRECTORY = -> () { Settings.load.directory }
|
14
|
-
GITHUB_REPO = -> () { Settings.load.github_repo }
|
15
13
|
EDITOR = ENV["VISUAL"] || ENV["EDITOR"] || "vim"
|
16
14
|
HIGHLIGHT_COLORS = {
|
17
15
|
0 => :yellow,
|
@@ -26,11 +24,11 @@ module Til
|
|
26
24
|
def self.init_settings_file_and_notes_repo
|
27
25
|
Initializer.new.create_settings_file unless Settings.settings_file_configured?
|
28
26
|
Initializer.new.create_notes_directory
|
29
|
-
puts "Your settings file is at `#{Settings.settings_file_path}`. Your notes are at `#{
|
27
|
+
puts "Your settings file is at `#{Settings.settings_file_path}`. Your notes are at `#{Settings.load.directory}`."
|
30
28
|
end
|
31
29
|
|
32
30
|
def self.print_working_directory
|
33
|
-
puts
|
31
|
+
puts Settings.load.directory
|
34
32
|
end
|
35
33
|
|
36
34
|
def self.new_note(subject, title)
|
@@ -40,7 +38,7 @@ module Til
|
|
40
38
|
end
|
41
39
|
|
42
40
|
if_modified = Proc.new do |note_content|
|
43
|
-
subject_path =
|
41
|
+
subject_path = Settings.load.directory + "/#{subject.downcase}"
|
44
42
|
if !File.directory? subject_path
|
45
43
|
FileUtils.mkdir(subject_path)
|
46
44
|
puts "Created a new directory for #{subject.downcase}"
|
@@ -91,10 +89,11 @@ module Til
|
|
91
89
|
end
|
92
90
|
|
93
91
|
def self.open_github_page_for_repo
|
94
|
-
if
|
92
|
+
if Settings.github_repo
|
93
|
+
system("open https://www.github.com/#{Settings.github_repo}")
|
95
94
|
else
|
96
95
|
begin
|
97
|
-
repo = %x|git --git-dir=#{
|
96
|
+
repo = %x|git --git-dir=#{Settings.load.directory}/.git --work-tree=#{Settings.load.directory} remote -v|.scan(/:(.*).git/).flatten.first
|
98
97
|
system("open https://www.github.com/#{repo}")
|
99
98
|
rescue
|
100
99
|
puts "You don't appear to have a GitHub remote repository for your notes."
|
@@ -103,16 +102,16 @@ module Til
|
|
103
102
|
end
|
104
103
|
|
105
104
|
def self.run_git_command(*args)
|
106
|
-
system("git --git-dir=#{
|
105
|
+
system("git --git-dir=#{Settings.load.directory}/.git --work-tree=#{Settings.load.directory} #{args.join(" ")}")
|
107
106
|
end
|
108
107
|
|
109
108
|
|
110
109
|
def self.run_grep_command(*args)
|
111
|
-
system("grep -r #{args.join(" ")} #{
|
110
|
+
system("grep -r #{args.join(" ")} #{Settings.load.directory}")
|
112
111
|
end
|
113
112
|
|
114
113
|
def self.run_ag_command(*args)
|
115
|
-
system("ag #{args.join(" ")} #{
|
114
|
+
system("ag #{args.join(" ")} #{Settings.load.directory}")
|
116
115
|
end
|
117
116
|
|
118
117
|
|
@@ -141,8 +140,8 @@ module Til
|
|
141
140
|
|
142
141
|
def self.list_subjects(list_style=:bullet_points)
|
143
142
|
subjects = Array.new
|
144
|
-
Dir.glob(
|
145
|
-
subjects.push dirname.gsub(
|
143
|
+
Dir.glob(Settings.load.directory + "/*").each do |dirname|
|
144
|
+
subjects.push dirname.gsub(Settings.load.directory + "/", "")
|
146
145
|
end
|
147
146
|
if list_style==:flat
|
148
147
|
puts subjects.join(", ")
|
data/lib/til/directory.rb
CHANGED
@@ -6,9 +6,9 @@ module Til
|
|
6
6
|
|
7
7
|
def initialize(subject=nil)
|
8
8
|
if subject
|
9
|
-
@path =
|
9
|
+
@path = Settings.load.directory + "/#{subject}/*.md"
|
10
10
|
else
|
11
|
-
@path =
|
11
|
+
@path = Settings.load.directory + "/**/*.md"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
data/lib/til/initializer.rb
CHANGED
@@ -6,9 +6,12 @@ module Til
|
|
6
6
|
include Thor::Actions
|
7
7
|
|
8
8
|
def create_settings_file
|
9
|
-
notes_directory = ask("What directory do you want your notes to live in? (If you have no preference, `~/til` is a good option.)\n>")
|
9
|
+
notes_directory = ask("What directory do you want your TIL notes to live in? (If you have no preference, `~/til` is a good option.)\n>")
|
10
|
+
github_repo = ask("Do you have a GitHub repo for your TIL notes? If so, enter it in the form `kevinlitchfield/til`.\n>")
|
11
|
+
|
10
12
|
settings_hash = {
|
11
|
-
"directory" => notes_directory
|
13
|
+
"directory" => notes_directory,
|
14
|
+
"github_repo" => github_repo
|
12
15
|
}
|
13
16
|
puts "Creating a settings file at `#{Settings.settings_file_path}`."
|
14
17
|
File.open(Settings.settings_file_path, "w") do |f|
|
@@ -17,7 +20,7 @@ module Til
|
|
17
20
|
end
|
18
21
|
|
19
22
|
def create_notes_directory
|
20
|
-
d = Settings.load.
|
23
|
+
d = Settings.load.directory
|
21
24
|
FileUtils.mkdir_p(File.expand_path(d))
|
22
25
|
end
|
23
26
|
end
|
data/lib/til/settings.rb
CHANGED
data/lib/til/version.rb
CHANGED