notenote 0.0.2 → 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/note/cli.rb +57 -4
- data/lib/note/config.json.template +2 -1
- data/lib/note/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b6879e1aa7c6522ca4115b8cc9e2bb35e5b35c56d3d844546fbf5207472bd6b
|
4
|
+
data.tar.gz: 1b88305949d1ae6d7d8b1b63a0704942f8b3bf14df7ddb47b9c976675e079b46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c710812b969e74bc21283132d006af95fa2883cbf64a510cf6bc32cf1170998ee770db5243cca139593094c1f181293781f6758e4d60734773cd6dbc5eab4c2
|
7
|
+
data.tar.gz: 582f0e27bb423fc3f54f5997c4d42d4c1ebf54f637e2a2931921ab4016af1e8f5e7ba4e5064a62ff5608d48b02dcdffc76143e81d572f6e40df400717011a786
|
data/lib/note/cli.rb
CHANGED
@@ -25,9 +25,13 @@ module Note
|
|
25
25
|
Dir.mkdir(notes_folder)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
notes_folder_full_path = File.join(Dir.pwd, notes_folder)
|
29
|
+
|
30
|
+
create_config_file(notes_folder: notes_folder_full_path)
|
31
|
+
create_readme_file
|
29
32
|
create_note_file
|
30
33
|
|
34
|
+
|
31
35
|
puts %(Your note folder "#{notes_folder}" and the first log file are created. You're ready to go! 🚀)
|
32
36
|
|
33
37
|
0
|
@@ -37,6 +41,29 @@ module Note
|
|
37
41
|
|
38
42
|
create_note_file(file_name: "#{file_name}.md")
|
39
43
|
|
44
|
+
0
|
45
|
+
elsif args.first == "all"
|
46
|
+
notes_folder = notenote_config["notes_folder"]
|
47
|
+
|
48
|
+
open_editor(path: notes_folder)
|
49
|
+
|
50
|
+
0
|
51
|
+
elsif args.first == "folder"
|
52
|
+
unless mac?
|
53
|
+
puts "Unfortunately, this command works only on Mac devices atm. Please, make a PR to support your OS. 🙏"
|
54
|
+
end
|
55
|
+
|
56
|
+
notes_folder = notenote_config["notes_folder"]
|
57
|
+
|
58
|
+
osascript <<-END
|
59
|
+
tell application "Terminal"
|
60
|
+
activate
|
61
|
+
tell application "System Events" to keystroke "t" using command down
|
62
|
+
do script "cd #{notes_folder}" in front window
|
63
|
+
do script "clear" in front window
|
64
|
+
end tell
|
65
|
+
END
|
66
|
+
|
40
67
|
0
|
41
68
|
else
|
42
69
|
puts "Hm, I don't know this command 🤔"
|
@@ -47,6 +74,20 @@ module Note
|
|
47
74
|
|
48
75
|
private
|
49
76
|
|
77
|
+
def create_readme_file
|
78
|
+
notes_folder = notenote_config["notes_folder"]
|
79
|
+
|
80
|
+
readme_file = File.join(notes_folder, "README.md")
|
81
|
+
|
82
|
+
File.open(readme_file, "w") do |file|
|
83
|
+
file.puts unindent <<-TEXT
|
84
|
+
# Daily notes
|
85
|
+
|
86
|
+
|
87
|
+
TEXT
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
50
91
|
def create_config_file(notes_folder:)
|
51
92
|
config_template = File.read(File.join(File.dirname(__FILE__), "config.json.template"))
|
52
93
|
|
@@ -72,7 +113,7 @@ module Note
|
|
72
113
|
|
73
114
|
FileUtils.touch(note_file)
|
74
115
|
|
75
|
-
open_editor(
|
116
|
+
open_editor(path: note_file)
|
76
117
|
end
|
77
118
|
|
78
119
|
def notenote_config
|
@@ -81,10 +122,22 @@ module Note
|
|
81
122
|
JSON.parse(File.read(config_file))
|
82
123
|
end
|
83
124
|
|
84
|
-
def open_editor(
|
125
|
+
def open_editor(path:)
|
85
126
|
editor_command = notenote_config["editor_command"]
|
86
127
|
|
87
|
-
system("#{editor_command} #{
|
128
|
+
system("#{editor_command} #{path}")
|
129
|
+
end
|
130
|
+
|
131
|
+
def mac?
|
132
|
+
RbConfig::CONFIG["host_os"] =~ /darwin/
|
133
|
+
end
|
134
|
+
|
135
|
+
def osascript(script)
|
136
|
+
system "osascript", *unindent(script).split(/\n/).map { |line| ['-e', line] }.flatten
|
137
|
+
end
|
138
|
+
|
139
|
+
def unindent(str)
|
140
|
+
str.gsub(/^#{str.scan(/^[ \t]+(?=\S)/).min}/, "")
|
88
141
|
end
|
89
142
|
end
|
90
143
|
end
|
data/lib/note/version.rb
CHANGED