hackpad-cli 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +22 -3
- data/lib/hackpad/cli.rb +13 -10
- data/lib/hackpad/cli/version.rb +1 -1
- data/lib/hackpad/client.rb +5 -6
- data/lib/hackpad/config.rb +13 -15
- 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: fb2500eed443d5bc32fb2c6a1c0fdbd85095037a
|
4
|
+
data.tar.gz: af50106dab8686626a27c6bba5085a6211717773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3531001771b33e3e8eeffee112b7e1f0075fabc32c6e10281c6b2df9eb81a7a30df2d0d51e7190f029f6aff51d8cc4b97fa47de8180cc35ae162a34b76b442dd
|
7
|
+
data.tar.gz: 93f097d8ded9f2a4e45cf9e5f914d14a116f9950e32b90daa832553d38829b2fba1aa2bbe50a113d2135a03aa031723c0bc832ddff2126fcb6eb067784a7c91b
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Hackpad-cli changelog
|
2
2
|
==========================
|
3
3
|
|
4
|
+
v0.0.3 - 2014-04-01
|
5
|
+
--------------
|
6
|
+
|
7
|
+
* add a better way to manage alternative configuration file
|
8
|
+
* fix alternate config dir setup
|
9
|
+
* verify compat with ruby 1.9.3
|
10
|
+
* better readme
|
11
|
+
|
4
12
|
v0.0.2 - 2014-04-01
|
5
13
|
---------------
|
6
14
|
|
data/README.md
CHANGED
@@ -2,9 +2,10 @@ Hackpad-Cli
|
|
2
2
|
===================
|
3
3
|
|
4
4
|
This is a command-line utility to check and manipulate hackpad documents.
|
5
|
-
It uses Hackpad REST API 1.0 https://hackpad.com/fQD2DRz22Wf
|
5
|
+
It uses Hackpad REST API 1.0 https://hackpad.com/fQD2DRz22Wf and was tested with ruby 1.9.3 and 2.1.1.
|
6
6
|
|
7
|
-
Initially this tool was created to overcome the frustration of the md export of pads,
|
7
|
+
Initially this tool was created to overcome the frustration of the md export of pads,
|
8
|
+
because we need to copy them to other places sometimes. Proper markdown would be appreciated.
|
8
9
|
|
9
10
|
So for now, it does that, by transforming the html in markdown with the https://github.com/xijo/reverse_markdown gem.
|
10
11
|
|
@@ -24,9 +25,27 @@ Usage
|
|
24
25
|
|
25
26
|
(use `bundle exec` if you need, mostly in clone mode when not using rvm)
|
26
27
|
|
27
|
-
hpcli
|
28
|
+
hpcli # will show help
|
29
|
+
hpcli list # gets a list of pads you have access to
|
28
30
|
hpcli get <pad_id> md # will spit out the content in nice markdown
|
31
|
+
# and you can use alternate config
|
32
|
+
hpcli list -w alt
|
29
33
|
|
34
|
+
At first launch it will create your config dir (default ~/.hackpad-cli/), and will ask you questions to create the config file (default is .. default.yml). If you pass the `-w whatever` option at the end, it will ask questions again to write whatever.yml config file.
|
35
|
+
|
36
|
+
|
37
|
+
Roadmap and todoz
|
38
|
+
---------------------
|
39
|
+
|
40
|
+
* cache the pads list in a local storage
|
41
|
+
* refresh cache according to last cached date
|
42
|
+
* add commands for creating a new pad, linked to $EDITOR
|
43
|
+
* add admin commands for managing users
|
44
|
+
* nag hackpad for they add REST endpoints to query collections
|
45
|
+
* write proper tests
|
46
|
+
* add freaking cool badges on the readme
|
47
|
+
* add a gateway to github so a pad could be copied over a wiki page directly or in a repo somehow
|
48
|
+
* implement pretty much all what the hackpad API v1 offers
|
30
49
|
|
31
50
|
Contributing
|
32
51
|
------------------
|
data/lib/hackpad/cli.rb
CHANGED
@@ -6,29 +6,32 @@ require_relative "client"
|
|
6
6
|
module Hackpad
|
7
7
|
|
8
8
|
class Cli < Thor
|
9
|
-
include Thor::Actions
|
10
|
-
|
11
|
-
default_task :help
|
12
9
|
|
13
10
|
class_option :configdir,
|
14
11
|
aliases: "-c",
|
15
|
-
banner: "PATH",
|
16
12
|
default: File.join(ENV["HOME"], ".hackpad-cli/"),
|
17
|
-
desc: "Path to the hackpad-cli directory to use"
|
13
|
+
desc: "Path to the hackpad-cli directory to use."
|
14
|
+
|
15
|
+
class_option :workspace,
|
16
|
+
aliases: "-w",
|
17
|
+
default: "default",
|
18
|
+
desc: "Name of the workspace to use."
|
19
|
+
|
20
|
+
default_task :help
|
18
21
|
|
19
22
|
desc "list", "Lists available pads."
|
20
23
|
def list
|
21
|
-
Hackpad::Client.new(options
|
24
|
+
Hackpad::Client.new(options).listall
|
22
25
|
end
|
23
26
|
|
24
|
-
desc "getinfo [pad_id]", "gets info for the pad <pad_id
|
27
|
+
desc "getinfo [pad_id]", "gets info for the pad <pad_id>."
|
25
28
|
def getinfo(pad)
|
26
|
-
Hackpad::Client.new(options
|
29
|
+
Hackpad::Client.new(options).getinfo pad
|
27
30
|
end
|
28
31
|
|
29
|
-
desc "show [pad_id] [format]", "shows pad <pad_id> in format [html,txt,md] (default txt)"
|
32
|
+
desc "show [pad_id] [format]", "shows pad <pad_id> in format [html,txt,md] (default txt)."
|
30
33
|
def show(pad,format='txt')
|
31
|
-
Hackpad::Client.new(options
|
34
|
+
Hackpad::Client.new(options).show pad, format
|
32
35
|
end
|
33
36
|
|
34
37
|
end
|
data/lib/hackpad/cli/version.rb
CHANGED
data/lib/hackpad/client.rb
CHANGED
@@ -8,9 +8,8 @@ require_relative 'config'
|
|
8
8
|
module Hackpad
|
9
9
|
class Client
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@
|
13
|
-
@config = Config.load configdir
|
11
|
+
def initialize(options)
|
12
|
+
@config = Config.load options
|
14
13
|
site = URI.parse @config['site']
|
15
14
|
consumer = OAuth::Consumer.new(
|
16
15
|
@config['client_id'],
|
@@ -21,12 +20,12 @@ module Hackpad
|
|
21
20
|
end
|
22
21
|
|
23
22
|
# GET /api/1.0/pads/all
|
24
|
-
def
|
23
|
+
def listall
|
25
24
|
res = @token.get "/api/1.0/pads/all"
|
26
25
|
if res.is_a? Net::HTTPSuccess
|
27
26
|
all = JSON.parse res.body
|
28
27
|
all.each do |a|
|
29
|
-
|
28
|
+
getinfo(a)
|
30
29
|
end
|
31
30
|
else
|
32
31
|
puts "#{res.inspect}".colorize :red
|
@@ -38,7 +37,7 @@ module Hackpad
|
|
38
37
|
def getinfo(pad)
|
39
38
|
res = @token.get "/api/1.0/pad/#{pad}/content.txt"
|
40
39
|
if res.is_a? Net::HTTPSuccess
|
41
|
-
puts "#{@config['site']}/#{pad} - #{res.body.lines.first.chomp}"
|
40
|
+
puts "#{@config['site']}/#{pad} - #{pad} - #{res.body.lines.first.chomp}"
|
42
41
|
else
|
43
42
|
puts "#{pad} failed".colorize :red
|
44
43
|
end
|
data/lib/hackpad/config.rb
CHANGED
@@ -2,18 +2,24 @@ module Hackpad
|
|
2
2
|
module Config
|
3
3
|
extend self
|
4
4
|
|
5
|
-
def load(
|
6
|
-
|
7
|
-
|
5
|
+
def load(options)
|
6
|
+
configdir = options[:configdir]
|
7
|
+
configfile = File.join(configdir, "#{options[:workspace]}.yml")
|
8
|
+
# temporary migration path
|
9
|
+
if !File.exists?(configfile) && File.exists?(File.join(configdir, "config.yml"))
|
10
|
+
FileUtils.mv File.join(configdir, "config.yml"), configfile
|
8
11
|
end
|
9
|
-
|
12
|
+
if !Dir.exists?(configdir) || !File.exists?(configfile)
|
13
|
+
setup configfile
|
14
|
+
end
|
15
|
+
YAML::load_file configfile
|
10
16
|
end
|
11
17
|
|
12
18
|
private
|
13
19
|
|
14
|
-
def setup(
|
20
|
+
def setup(configfile)
|
15
21
|
config = {}
|
16
|
-
FileUtils.mkdir_p
|
22
|
+
FileUtils.mkdir_p File.dirname(configfile)
|
17
23
|
puts "We need first to initialize your hackpad-cli configuration.".colorize(:blue)
|
18
24
|
puts "Please gather your information from https://<subdomain>.hackpad.com/ep/account/settings/"
|
19
25
|
print "What is your Client ID? "
|
@@ -25,18 +31,10 @@ module Hackpad
|
|
25
31
|
print "What is the URI of your pad? "
|
26
32
|
STDOUT.flush
|
27
33
|
config['site'] = STDIN.gets.chomp
|
28
|
-
File.open(
|
34
|
+
File.open(configfile, "w") do |f|
|
29
35
|
f.write YAML::dump(config)
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
33
|
-
def conf_file
|
34
|
-
File.join(conf_dir, 'config.yml')
|
35
|
-
end
|
36
|
-
|
37
|
-
def conf_dir(dir = "#{ENV["HOME"]}/.hackpad-cli/")
|
38
|
-
dir
|
39
|
-
end
|
40
|
-
|
41
39
|
end
|
42
40
|
end
|