liste 1.0.0 → 2.0.0

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
  SHA1:
3
- metadata.gz: 297f94ef59a72cd7baed74d73965cc2a0679d3ec
4
- data.tar.gz: 007c79e886df519ec69ae74bdf105a9ea1cad382
3
+ metadata.gz: 3ca007b32ac7ec61eb742b2a184ad711f2a8b76d
4
+ data.tar.gz: 79db07ae0f9b180e9813869d2ebfb2bb69d34c36
5
5
  SHA512:
6
- metadata.gz: dc48bca90cd02443d58d700f60d8c1ed0d72d0e43c25a28c0f82f840b6534009b8febb7ead12f7450b08738bc298ad8f842b2e6fe99e3c0173a2897f707bb896
7
- data.tar.gz: d768da6d52e7bed5a5dc95d3df5a8e52fc2cf4644ae0e90acd9b8202415666fb5e43e969b26c4570d35841326febe446caf6fa1ffacc6da83192aee1926e8d16
6
+ metadata.gz: 54b5248dd3a276736823ae5a75f4c30ed73674b63eeda1441969d625ba3c6b426ee015ebbb875ace6bb5200f0bba6a2c58dfc94dad75512ce63e6ceb61006744
7
+ data.tar.gz: dc483c460f7236c30b03030a2ae0c6a24d4e2bc06697cac24dca049ad4207a74d409f26c10fa79afa364432698bbc01e592f6744cfceaee10389fd19fdd260e4
data/README.md CHANGED
@@ -8,30 +8,55 @@ for your own system of notes and reminders.
8
8
 
9
9
  ## Installation
10
10
 
11
- It doesn't get that much harder than this:
11
+ It doesn't get that much easier than this:
12
12
 
13
- + `sudo gem install liste`
14
- + `printf "\nliste login" >> ~/.bashrc`
13
+ + `sudo gem install liste` Download & install via RubyGems
14
+ + `printf "\nliste login" >> ~/.bashrc` If you want the custom login messages option
15
+ + `liste` Do this on first run to initialize the list file
15
16
 
16
17
  ## Usage
17
18
 
18
19
  Liste is not hard to use either, running `liste` by itself will
19
- display your todo list. `liste do "Anything I need to do"` adds
20
- to your todo list. Add to your terminal login messages list with
21
- `liste add login "CTRL + D logs you out of bash automatically"`.
20
+ display your todo list.
22
21
 
23
- Copied straight from `liste help`:
22
+ ### Add to your todo list
23
+ `liste "Any content goes here"`
24
24
 
25
- do task : add 'task' to the todo list
26
- add list task : add 'task' to 'list'
27
- disp list : display content of 'list'
28
- login : show your login list
29
- mark list done 1 : remove line 1 from list
30
- edit list : open list in editor
31
- rmi : interactively remove lists
32
- rm list1 list2 etc : remove lists list1, list2, etc
25
+ Pretty simple huh? That will add "Any content goes here" to your todo list.
33
26
 
34
- ### Contribute
27
+ Important: *Be sure to have some sort of whitespace in the content, or it will not be added correctly.*
28
+
29
+ ### Have custom login messages
30
+ Add to your terminal login messages list with:
31
+
32
+ `liste .login "My login reminder"`
33
+
34
+ As soon as you login (open a new terminal window), you will see this :
35
+
36
+ ```
37
+ Your tasks...
38
+
39
+ • My login reminder
40
+
41
+ you@host:~$
42
+ ```
43
+
44
+ ### Create and add to any other list
45
+ If you think that a 'login' and 'todo' list isn't enough, you can make a new list:
46
+
47
+ `liste .anylistname "Content to add to your custom list"`
48
+
49
+ To view this new list (this is sort of important), you can use `disp` like so:
50
+
51
+ `liste .anylistname disp`
52
+
53
+ Note: Although it's possible to have spaces in your list name (`liste ".spaces in this list name" "This list has spaces"`),
54
+ you would have to put quotes around the name, so it's clumsy and not recommended.
55
+
56
+ ### Other usage help
57
+ Run `liste help` for more complete usage instructions.
58
+
59
+ ## Contribute
35
60
 
36
61
  The feature you want isn't going to come out of nowhere
37
62
 
@@ -41,5 +66,5 @@ The feature you want isn't going to come out of nowhere
41
66
  4. Push to the branch `git push origin my-new-feature`
42
67
  5. Create a new Pull Request on github
43
68
 
44
- + [Daniel Ethridge](https://github.com/wlib) - author
45
- + [You](https://yourwebsite.com) - helped add...
69
+ + [Daniel Ethridge](https://wlib.github.io) - author
70
+ + [You](https://yourwebsite.com) - helped add...
data/bin/liste CHANGED
@@ -2,67 +2,34 @@
2
2
  # Liste - reminders, notes, ideas on the go
3
3
  # Daniel Ethridge
4
4
 
5
- require 'fileutils'
5
+ require "liste"
6
+ include Liste
6
7
 
7
- args = ARGV.map(&:downcase)
8
+ # 'argv' will be the lowercase version of 'ARGV', this helps for argument matching
9
+ argv = ARGV.map(&:downcase)
8
10
 
9
- # Creates a new list
10
- def init(list)
11
- unless File.directory?("#{Dir.home}/.liste")
12
- FileUtils.mkdir_p("#{Dir.home}/.liste")
13
- end
14
- File.open("#{Dir.home}/.liste/#{list}.list", "w")
15
- puts "New list created in '#{Dir.home}/.liste/#{list}.list'\n"
16
- end
11
+ help = "\nUsage : `liste` or `liste [arguments]` or
12
+ `liste .listname \"task\"` or `liste .listname [arguments]`
17
13
 
18
- # Pretty-prints a list's contents
19
- def disp(listname, style)
20
- list = File.open("#{Dir.home}/.liste/#{listname}.list", "r") rescue init(listname)
21
- case style
22
- when "bullet"
23
- bullet = "\u2022"
24
- File.foreach(list) do |line|
25
- puts " #{bullet} #{line}"
26
- end
27
- when "check"
28
- check = "\u2714"
29
- File.foreach(list) do |line|
30
- puts " #{check} #{line}"
31
- end
32
- when "number"
33
- File.foreach(list).with_index do |line, i|
34
- puts "#{i+1}. #{line}"
35
- end
36
- end
37
- print "\n"
38
- end
14
+ Liste is for those who have short-term memory and
15
+ those who need constant reminders.
16
+ You should add the line 'liste login' to your .bashrc
39
17
 
40
- # Shortcut the manually edit a list
41
- def edit_list(list = "todo")
42
- system "editor #{Dir.home}/.liste/#{list}.list" rescue edit_list()
43
- end
18
+ When adding an item to a list, the content MUST contain whitespace to be
19
+ selected, this is accomplished by adding quotes around your list item :
20
+ `liste .list \"my content has whitespace\"` This is done to prevent the shell
21
+ from splitting your content into seperate arguments.
44
22
 
45
- # Simple interactive list remover
46
- def rmi()
47
- puts "Type which of these lists to remove, type `exit` when done\n\n"
48
- dir = Dir["#{Dir.home}/.liste/*.list"].join("\n") rescue exit
49
- puts dir.scan(/(?<=\.liste\/)(.*?)(?=\.list)/)
50
- print "\nremove> "
51
- input = $stdin.gets.chomp
52
- if input == "exit"; exit; end
53
- FileUtils.rm_r("#{Dir.home}/.liste/#{input}.list") rescue rmi()
54
- puts "List '#{input}' removed"
55
- end
23
+ --------------------------------------------------
56
24
 
57
- # Removes an array of lists
58
- def rm_lists(lists)
59
- i = 0
60
- while i < lists.length
61
- FileUtils.rm_r("#{Dir.home}/.liste/#{lists[i]}.list") rescue rmi()
62
- i += 1
63
- end
64
- puts "List(s) '#{lists.join(', ')}' removed"
65
- end
25
+ \"task to do\" : add 'task' to the todo list
26
+ .login \"task to do\" : add 'task' to the login list
27
+ .anylist disp : display the contents of 'anylist'
28
+
29
+ --------------------------------------------------
30
+
31
+ If you find a bug, want extra features, or have a suggestion,
32
+ make a branch on github : https://github.com/wlib/liste\n\n"
66
33
 
67
34
  # Just running `liste` (no arguments) will display content of the "todo" list
68
35
  if ARGV.empty?
@@ -72,79 +39,49 @@ if ARGV.empty?
72
39
  exit
73
40
  end
74
41
 
75
- # Defines how the arguments are interpretted
76
- case args[0]
42
+ case argv[0]
77
43
  when "?", "h", "help", "-h", "--help"
78
- puts "\nUsage : `liste` or `liste [arguments]`\n\n\
79
- Liste is for those who have short-term memory and\n\
80
- those who need constant reminders.\n\
81
- You should add the line 'liste login' to your .bashrc\n\n\
82
- do task : add 'task' to the todo list\n\
83
- add list task : add 'task' to 'list'\n\
84
- disp list : display content of 'list'\n\
85
- login : show your login list\n\
86
- mark list done 1 : remove line 1 from list\n\
87
- edit list : open list in editor\n\
88
- rmi : interactively remove lists\n\
89
- rm list1 list2 etc : remove lists list1, list2, etc\n\n\
90
- If you find a bug, want extra features, or have a suggestion, make a branch\n\
91
- on github : https://github.com/wlib/liste\n\n"
92
- # `liste do "my task"` adds "my task" to the "todo" list
93
- when "do"
94
- todo = File.open("#{Dir.home}/.liste/todo.list", "a") rescue
95
- init("todo"); todo = File.open("#{Dir.home}/.liste/todo.list", "a")
96
- todo << "#{ARGV[1..-1].join(' ')}\n"
97
- exit
98
- # `liste add login "my reminder"` adds a line to the list "login"
99
- when "add"
100
- list = File.open("#{Dir.home}/.liste/#{ARGV[1]}.list", "a") rescue
101
- init("#{ARGV[1]}"); list = File.open("#{Dir.home}/.liste/#{ARGV[1]}.list", "a")
102
- list << "#{ARGV[2..-1].join(' ')}\n"
103
- exit
104
- # Displays the content in any list
105
- when "disp"
106
- puts "Your list '#{ARGV[1]}'...\n\n"
107
- disp("#{ARGV[1]}", "bullet") rescue
108
- puts "...nothing here yet"; exit
44
+ puts help
109
45
  exit
110
46
  # This displays the "login" list
111
47
  when "login"
112
48
  puts "Your tasks...\n\n"
113
49
  disp("login", "bullet") rescue
114
- puts "...nothing here yet"; exit
50
+ puts "\n...nothing here yet"; exit
115
51
  exit
116
- # Marks a list or line in a list a certain way...
117
- when "mark"
118
- case args[2]
119
- # Marks a line as done, removes from that list, adds to the "done" list
120
- when "done"
121
- listfile = File.open("#{Dir.home}/.liste/#{args[1]}.list", "r+") rescue exit
122
- todo = listfile.readlines
123
- listfile.close
124
- done = File.open("#{Dir.home}/.liste/done.list", "a") rescue
125
- done_init(); done = File.open("#{Dir.home}/.liste/done.list", "a")
126
- line_index = args[3].to_i - 1
127
- if line_index >= todo.length; puts "check line number"; exit end
128
- done.puts todo[line_index]
129
- todo.delete_at(line_index)
130
- listfile = File.open("#{Dir.home}/.liste/#{args[1]}.list", "w")
131
- listfile.puts todo
132
- exit
133
- else
134
- puts "not sure what to mark... did you mean `liste mark [list] done [line #]`"
135
- end
136
52
  # Calls the edit shortcut
137
53
  when "edit"
138
- edit_list(ARGV[1])
54
+ edit_list()
139
55
  exit
140
- # Calls interactive list deletion
141
- when "rmi"
142
- rmi()
143
- # Calls deletion of one or more lists
144
- when "rm"
145
- if args.length < 2; puts "did you mean `liste rmi` for interactive list removal?"; exit end
146
- rm_lists(ARGV[1..-1])
56
+ end
57
+
58
+ # Parse shell input in the format `liste .listname ["content" / arguments]`
59
+ if argv[0].start_with?('.')
60
+ listname = ARGV[0][1..-1]
61
+ end
62
+ content = ARGV.select{ |e| e[/\s/] }.join(' ')
63
+ args = ARGV[1..-1].select{ |e| ! e[/\s/] }.map(&:downcase)
64
+
65
+ # Add content to the todo list, alternatively add to any other list
66
+ unless content.empty?
67
+ if ! listname.nil?
68
+ add(listname, content) rescue newlist(listname, content)
69
+ exit
70
+ elsif listname.nil?
71
+ add("todo", content) rescue newlist("todo", content)
72
+ exit
73
+ end
74
+ end
75
+
76
+ # More than one list argument can be run at a time
77
+ case
78
+ # Displays the content in any list
79
+ when args.include?("disp")
80
+ puts "Your list '#{listname}'...\n\n"
81
+ disp("#{listname}", "bullet") rescue
82
+ puts "\n...nothing here yet"; exit
147
83
  exit
148
- else
149
- puts "Your first argument was not valid"
150
- end
84
+ end
85
+
86
+ # If nothing is caught then throw an error message
87
+ puts "Something went wrong, I'm not sure what you want me to do"; exit
Binary file
data/lib/liste.rb ADDED
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+ # Functions used in liste
3
+ # Daniel Ethridge
4
+
5
+ module Liste
6
+ # Creates a new list
7
+ def init()
8
+ unless File.directory?("#{Dir.home}/.liste")
9
+ require 'fileutils'
10
+ FileUtils.mkdir_p("#{Dir.home}/.liste")
11
+ end
12
+ File.open("#{Dir.home}/.liste/main.list", "w")
13
+ puts "New list created in '#{Dir.home}/.liste/main.list'\n\n"
14
+ end
15
+
16
+ def newlistfile(listname, content, path)
17
+ hash = { :"#{listname}" => {:l0 => content} }
18
+ json = JSON.pretty_generate(hash)
19
+ file = File.open("#{path}", 'w')
20
+ file.puts json
21
+ file.close
22
+ puts "new list '#{listname}' created"
23
+ end
24
+
25
+ def newlist(listname, content="This is a placeholder", path="#{Dir.home}/.liste/main.list")
26
+ require 'json'
27
+ file = File.open("#{path}", 'r')
28
+ listfile = file.read
29
+ file.close
30
+ if listfile.nil? || listfile.empty?; newlistfile(listname, content, path); exit end
31
+ listhash = { :"#{listname}" => {:l0 => content } }
32
+ hash = JSON.parse(listfile)
33
+ newhash = hash.merge!(listhash)
34
+ json = JSON.pretty_generate(newhash)
35
+ file = File.open("#{path}", 'w')
36
+ file.puts json
37
+ file.close
38
+ end
39
+
40
+ # Make a list item and add to the json list file
41
+ def add(listname, content, path="#{Dir.home}/.liste/main.list")
42
+ require 'json'
43
+ file = File.open("#{path}", 'r')
44
+ listfile = file.read
45
+ file.close
46
+ listhash = JSON.parse(listfile)
47
+ if ! listhash.keys.include? listname; newlist(listname) end
48
+ listcontent = listhash[listname]
49
+ i = 0
50
+ while listcontent.keys.include? "l#{i}"
51
+ i += 1
52
+ end
53
+ newcontent = { "l#{i}" => content }
54
+ listcontent.merge!(newcontent)
55
+ newjson = JSON.pretty_generate(listhash)
56
+ file = File.open("#{path}", 'w')
57
+ file.puts newjson
58
+ file.close
59
+ end
60
+
61
+ def putlines(listname)
62
+ require 'json'
63
+ file = File.open("#{Dir.home}/.liste/main.list") rescue init()
64
+ listfile = file.read
65
+ listhash = JSON.parse(listfile)
66
+ linesout = []
67
+ i = 0
68
+ while i < listhash[listname].count
69
+ line = listhash[listname]["l#{i}"]
70
+ linesout << "#{line}"
71
+ i += 1
72
+ end
73
+ linesout
74
+ end
75
+
76
+ # Pretty-prints a list's contents
77
+ def disp(listname, style)
78
+ bullet = "\u2022"
79
+ check = "\u2714"
80
+ linesout = putlines(listname)
81
+ case style
82
+ when "bullet"
83
+ linesout.each do |line|
84
+ puts " #{bullet} #{line}"
85
+ end
86
+ when "check"
87
+ linesout.each do |line|
88
+ puts " #{check} #{line}"
89
+ end
90
+ when "number"
91
+ linesout.each.with_index do |line, i|
92
+ puts "#{i+1}. #{line}"
93
+ end
94
+ end
95
+ print "\n"
96
+ end
97
+
98
+ # Shortcut the manually edit a list
99
+ def edit_list()
100
+ system "editor #{Dir.home}/.liste/main.list" rescue edit_list()
101
+ end
102
+ end
data/lib/liste/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Liste
2
- VERSION = "1.0.0"
3
- end
2
+ VERSION = "2.0.0"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liste
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Ethridge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-05 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,8 @@ files:
52
52
  - Rakefile
53
53
  - bin/liste
54
54
  - bin/setup
55
+ - gems/liste-1.0.0.gem
56
+ - lib/liste.rb
55
57
  - lib/liste/version.rb
56
58
  - liste.gemspec
57
59
  homepage: https://github.com/wlib/liste