/
springpad
executable file
·54 lines (48 loc) · 1.88 KB
/
springpad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
require 'rubygems'
require 'commander/import'
require_relative "../lib/springpad"
program :version, Springpad::VERSION
program :description, 'Command-line client to the Springpad API.'
program :help, 'Author', 'Josep M. Bach (Txus) <josep.m.bach@gmail.com>'
command :list do |c|
c.syntax = 'springpad list TYPE [options]'
c.summary = 'Lists all elements of a certain TYPE.'
c.description = 'Springpad blocks have an associated type, for example Note or Task. This command lists every block you own of a certain type. The result can be filtered using [options].'
c.example 'List all private notes', 'springpad list note --private'
c.option '--private', 'Show only private blocks'
c.action do |args, options|
type = args.first
unless type
warn "A TYPE must be specified. To know about available types, run:"
warn " $ springpad types"
abort
end
Springpad.list(type, options)
end
end
command :add do |c|
c.syntax = 'springpad add TYPE [options]'
c.summary = 'Adds an element of a certain TYPE.'
c.description = 'Creates a new element of TYPE with custom properties [options]. $EDITOR will be used to create the element. The first line of the element will be its name, the other lines will vary accordying the element type.'
c.example 'Create a new private note', 'springpad add note --private'
c.option '--private', 'Make the new block private'
c.action do |args, options|
type = args.first
unless type
warn "A TYPE must be specified. To know about available types, run:"
warn " $ springpad types"
abort
end
Springpad.add(type, options)
end
end
command :types do |c|
c.syntax = 'springpad types'
c.summary = 'Lists the supported element types.'
c.description = ''
c.action do |args, options|
types = Springpad::Blocks.types
puts "Supported types are: #{types.join(', ')}"
end
end