twitter-lists-cli 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +47 -1
- data/VERSION.yml +1 -1
- data/bin/twitter-auth +2 -2
- data/bin/twitter-follow +27 -23
- data/bin/twitter-following +6 -4
- data/bin/twitter-lists +12 -4
- metadata +2 -2
data/README.md
CHANGED
@@ -4,11 +4,57 @@ A command-line client for manipulating large Twitter lists in the shell, shell s
|
|
4
4
|
|
5
5
|
Currently supports
|
6
6
|
------------------
|
7
|
-
- OAuth authentication
|
7
|
+
- OAuth authentication (twitter-auth)
|
8
8
|
- Showing a users's followers/following
|
9
9
|
- Following and unfollowing users
|
10
10
|
- Showing, adding, and removing a members from a list
|
11
11
|
|
12
|
+
Commands included:
|
13
|
+
------------------
|
14
|
+
### twitter-auth
|
15
|
+
usage: twitter-auth
|
16
|
+
Get OAuth credentials.
|
17
|
+
|
18
|
+
Global Options:
|
19
|
+
--auth FILE Read authentication data from the specified FILE
|
20
|
+
|
21
|
+
### twitter-follow
|
22
|
+
usage: twitter-follow [-l LISTNAME] [--only | -d] [USER...]
|
23
|
+
Follow or unfollow users.
|
24
|
+
|
25
|
+
-l, --list LISTNAME act on the specified LISTNAME instead of the logged-in user
|
26
|
+
-d, --unfollow unfollow the specified users
|
27
|
+
|
28
|
+
If no USERs are specified on the command line, they will be read from stdin.
|
29
|
+
|
30
|
+
Global Options:
|
31
|
+
--auth FILE Read authentication data from the specified FILE
|
32
|
+
|
33
|
+
### twitter-following
|
34
|
+
usage: twitter-following [-r] [-u USER] [-l LISTNAME]
|
35
|
+
Show who is being followed by a user or a list.
|
36
|
+
|
37
|
+
-u, --user USER specify a username (default is the logged-in user)
|
38
|
+
-l, --list LISTNAME show members of the user's LISTNAME instead of the user's followers
|
39
|
+
-r, --reverse show followers instead of who is following
|
40
|
+
|
41
|
+
Global options:
|
42
|
+
--auth FILE Read authentication data from the specified FILE
|
43
|
+
|
44
|
+
### twitter-lists
|
45
|
+
usage: twitter-lists [-s] [-u USER] [-c LISTNAME... | -C LISTNAME... | -d LISTNAME...]
|
46
|
+
Show, create, or delete lists.
|
47
|
+
-u, --user USER specify a username (default is the logged-in user)
|
48
|
+
-c, --create create the specified list(s)
|
49
|
+
-C, --create-private create private list(s)
|
50
|
+
-d, --delete delete the specified list(s)
|
51
|
+
-s, --slugs Use slugs instead of (possibly non-unique) names
|
52
|
+
|
53
|
+
If no LISTNAMEs are specified on the command line, they will be read from stdin.
|
54
|
+
|
55
|
+
Global options:
|
56
|
+
--auth FILE Read authentication data from the specified FILE
|
57
|
+
|
12
58
|
License
|
13
59
|
-------
|
14
60
|
Copyright (c) 2010 Dwayne Litzenberger
|
data/VERSION.yml
CHANGED
data/bin/twitter-auth
CHANGED
@@ -5,8 +5,8 @@ require 'twitter'
|
|
5
5
|
# Parse arguments
|
6
6
|
options = {:only => false, :unfollow=>false}
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.banner = "#{opts.program_name}"
|
9
|
-
opts.separator "Get OAuth credentials"
|
8
|
+
opts.banner = "usage: #{opts.program_name}"
|
9
|
+
opts.separator "Get OAuth credentials."
|
10
10
|
opts.separator ""
|
11
11
|
opts.separator "Global Options:"
|
12
12
|
opts.on("--auth FILE", "Read authentication data from the specified FILE") do |optarg|
|
data/bin/twitter-follow
CHANGED
@@ -5,8 +5,8 @@ require 'twitter'
|
|
5
5
|
# Parse arguments
|
6
6
|
options = {:only => false, :unfollow=>false}
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.banner = "#{opts.program_name} [-l LISTNAME] [--only | -d] [USER...]"
|
9
|
-
opts.separator "Follow or unfollow users"
|
8
|
+
opts.banner = "usage: #{opts.program_name} [-l LISTNAME] [--only | -d] [USER...]"
|
9
|
+
opts.separator "Follow or unfollow users."
|
10
10
|
opts.separator ""
|
11
11
|
opts.on("-l", "--list LISTNAME", "act on the specified LISTNAME instead of the logged-in user") do |optarg|
|
12
12
|
options[:list] = optarg
|
@@ -54,30 +54,34 @@ if options[:list]
|
|
54
54
|
end
|
55
55
|
|
56
56
|
options[:users].each do |user|
|
57
|
-
|
58
|
-
if options[:
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
else
|
69
|
-
if options[:unfollow]
|
70
|
-
begin
|
71
|
-
base.friendship_destroy(user)
|
72
|
-
rescue Twitter::TwitterError => e
|
73
|
-
raise unless e.data["error"] == "You are not friends with the specified user."
|
57
|
+
begin
|
58
|
+
if options[:list]
|
59
|
+
if options[:unfollow]
|
60
|
+
begin
|
61
|
+
base.list_remove_member(options[:user], options[:list], user)
|
62
|
+
rescue Twitter::TwitterError => e
|
63
|
+
# Don't raise exception if the user is already removed
|
64
|
+
raise unless e.data['error'] == "The user you are trying to remove from the list is not a member"
|
65
|
+
end
|
66
|
+
else
|
67
|
+
base.list_add_member(options[:user], options[:list], user)
|
74
68
|
end
|
75
69
|
else
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
70
|
+
if options[:unfollow]
|
71
|
+
begin
|
72
|
+
base.friendship_destroy(user)
|
73
|
+
rescue Twitter::TwitterError => e
|
74
|
+
raise unless e.data["error"] == "You are not friends with the specified user."
|
75
|
+
end
|
76
|
+
else
|
77
|
+
begin
|
78
|
+
base.friendship_create(user, true)
|
79
|
+
rescue Twitter::TwitterError => e
|
80
|
+
raise unless e.data["error"] =~ /\ACould not follow user: (.* is already on your list\.|You've already requested to follow .*)\Z/
|
81
|
+
end
|
80
82
|
end
|
81
83
|
end
|
84
|
+
rescue Twitter::TwitterError => e
|
85
|
+
$stderr.puts "#{$0}: error: #{user}: #{e}"
|
82
86
|
end
|
83
87
|
end
|
data/bin/twitter-following
CHANGED
@@ -5,12 +5,15 @@ require 'twitter'
|
|
5
5
|
# Parse arguments
|
6
6
|
options = {}
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.banner = "#{opts.program_name} [-r] [-u USER] [LISTNAME]"
|
9
|
-
opts.separator "Show who is being followed by a user or a list"
|
8
|
+
opts.banner = "usage: #{opts.program_name} [-r] [-u USER] [-l LISTNAME]"
|
9
|
+
opts.separator "Show who is being followed by a user or a list."
|
10
10
|
opts.separator ""
|
11
11
|
opts.on("-u", "--user USER", "specify a username (default is the logged-in user)") do |optarg|
|
12
12
|
options[:user] = optarg
|
13
13
|
end
|
14
|
+
opts.on("-l", "--list LISTNAME", "show members of the user's LISTNAME instead of the user's followers") do |optarg|
|
15
|
+
options[:list] = optarg
|
16
|
+
end
|
14
17
|
opts.on("-r", "--reverse", "show followers instead of who is following") do |optarg|
|
15
18
|
options[:reverse] = optarg
|
16
19
|
end
|
@@ -24,8 +27,7 @@ end.parse!
|
|
24
27
|
options[:auth_file] ||= ENV["TWITTER_AUTHFILE"]
|
25
28
|
options[:auth_file] ||= File.expand_path("~/.twitter")
|
26
29
|
raise "No --auth file specified" unless options[:auth_file] # XXX TODO - output usage information
|
27
|
-
raise "Too many arguments specified"
|
28
|
-
options[:list] = ARGV[0]
|
30
|
+
raise "Too many arguments specified" unless ARGV.empty? # XXX TODO - output usage information
|
29
31
|
|
30
32
|
auth = YAML.load_file(options[:auth_file])
|
31
33
|
oauth = Twitter::OAuth.new(auth["token"], auth["secret"])
|
data/bin/twitter-lists
CHANGED
@@ -3,16 +3,20 @@ require 'optparse'
|
|
3
3
|
require 'twitter'
|
4
4
|
|
5
5
|
# Parse arguments
|
6
|
-
options = {:create => false, :delete => false}
|
6
|
+
options = {:create => false, :delete => false, :private => false}
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.banner = "#{opts.program_name} [-s] [-u USER] [-c LISTNAME... | -d LISTNAME...]"
|
9
|
-
opts.separator "Show, create, or delete lists"
|
8
|
+
opts.banner = "usage: #{opts.program_name} [-s] [-u USER] [-c LISTNAME... | -C LISTNAME... | -d LISTNAME...]"
|
9
|
+
opts.separator "Show, create, or delete lists."
|
10
10
|
opts.on("-u", "--user USER", "specify a username (default is the logged-in user)") do |optarg|
|
11
11
|
options[:user] = optarg
|
12
12
|
end
|
13
13
|
opts.on("-c", "--create", "create the specified list(s)") do |optarg|
|
14
14
|
options[:create] = true
|
15
15
|
end
|
16
|
+
opts.on("-C", "--create-private", "create private list(s)") do |optarg|
|
17
|
+
options[:create] = true
|
18
|
+
options[:private] = true
|
19
|
+
end
|
16
20
|
opts.on("-d", "--delete", "delete the specified list(s)") do |optarg|
|
17
21
|
options[:delete] = true
|
18
22
|
end
|
@@ -61,7 +65,11 @@ options[:user] ||= base.verify_credentials.screen_name
|
|
61
65
|
|
62
66
|
if options[:create]
|
63
67
|
options[:lists].each do |list|
|
64
|
-
|
68
|
+
if options[:private]
|
69
|
+
base.list_create(options[:user], :name => list, :mode => "private")
|
70
|
+
else
|
71
|
+
base.list_create(options[:user], :name => list)
|
72
|
+
end
|
65
73
|
end
|
66
74
|
elsif options[:delete]
|
67
75
|
options[:lists].each do |list|
|