twig 1.6 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/twig-diff CHANGED
@@ -1,33 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Synopsis:
4
- #
5
- # twig diff [<branch>] [<options>]
6
- #
7
- # Description:
8
- #
9
- # Shows the diff between the current branch and its `diff-branch` property.
10
- # All options are passed through to `git-diff`.
11
- #
12
- # Examples:
13
- #
14
- # Show diff stats between the current branch and its `diff-branch`:
15
- #
16
- # twig diff --stat
17
- #
18
- # Show the diff between the given branch and its `diff-branch`:
19
- #
20
- # twig diff my_branch
21
- #
22
- # Show diff stats between the given branch and its `diff-branch`:
23
- #
24
- # twig diff my_branch --stat
25
- #
26
- # Subcommand for Twig: <http://rondevera.github.io/twig/>
27
- # Author: Ron DeVera <http://rondevera.com>
3
+ def help_content
4
+ <<-HELP
5
+
6
+ twig-diff
7
+ =========
8
+
9
+ Shows the diff between a branch and its parent branch (`diff-branch`).
10
+
11
+ Synopsis
12
+ --------
13
+
14
+ twig diff [<branch>] [<options>]
15
+
16
+ Description
17
+ -----------
18
+
19
+ Shows the diff between the current branch and its `diff-branch` property. All
20
+ options are passed through to `git-diff`.
21
+
22
+ Examples
23
+ --------
24
+
25
+ Show diff stats between the current branch and its `diff-branch`:
26
+
27
+ twig diff --stat
28
+
29
+ Show the diff between the given branch and its `diff-branch`:
30
+
31
+ twig diff my_branch
32
+
33
+ Show diff stats between the given branch and its `diff-branch`:
34
+
35
+ twig diff my_branch --stat
36
+
37
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
38
+ Author: Ron DeVera <http://rondevera.com>
39
+
40
+ HELP
41
+ end
28
42
 
29
43
  args = ARGV.dup
30
44
 
45
+ if args.include?('--help')
46
+ puts help_content
47
+ exit
48
+ end
49
+
31
50
  branch_given = args.any? && args.first[0, 1] != '-'
32
51
  topic_branch = args.shift.strip if branch_given # Use given branch
33
52
  topic_branch ||= `git rev-parse --abbrev-ref HEAD`.strip # Use current branch
data/bin/twig-gh-open CHANGED
@@ -1,26 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Synopsis:
4
- #
5
- # twig gh-open
6
- #
7
- # Description:
8
- #
9
- # Opens a browser window for the current GitHub repo.
10
- #
11
- # To customize the GitHub URI prefix (e.g., for GitHub Enterprise
12
- # installations), set GitHub options in `~/.twigconfig`:
13
- #
14
- # github-uri-prefix: http://example-enterprise.github.com
15
- # github-api-uri-prefix: http://example-enterprise.github.com
16
- #
17
- # Subcommand for Twig: <http://rondevera.github.io/twig/>
18
- # Author: Ron DeVera <http://rondevera.com>
19
-
20
3
  require 'rubygems'
21
4
  require 'twig'
22
5
  require 'launchy'
23
6
 
7
+ def help_content
8
+ <<-HELP
9
+
10
+ twig-gh-open
11
+ ============
12
+
13
+ Opens a browser window for the current GitHub repository.
14
+
15
+ Synopsis
16
+ --------
17
+
18
+ twig gh-open
19
+
20
+ Description
21
+ -----------
22
+
23
+ Opens a browser window for the current GitHub repository.
24
+
25
+ To customize the GitHub URI prefix (e.g., for GitHub Enterprise
26
+ installations), set GitHub options in `~/.twigconfig`:
27
+
28
+ github-uri-prefix: http://example-enterprise.github.com
29
+ github-api-uri-prefix: http://example-enterprise.github.com
30
+
31
+ See also
32
+ --------
33
+
34
+ twig-gh-open-issue
35
+ twig-gh-update
36
+
37
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
38
+ Author: Ron DeVera <http://rondevera.com>
39
+
40
+ HELP
41
+ end
42
+
43
+ args = ARGV.dup
44
+
45
+ if args.include?('--help')
46
+ puts help_content
47
+ exit
48
+ end
49
+
24
50
  Twig::GithubRepo.new do |gh_repo|
25
51
  twig = Twig.new(:read_options => true)
26
52
  gh_uri_prefix = twig.options[:github_uri_prefix]
@@ -1,30 +1,57 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Synopsis:
4
- #
5
- # twig gh-open-issue [-b|--branch <branch>]
6
- #
7
- # Description:
8
- #
9
- # Opens a browser window the GitHub issue, if any, for the current branch.
10
- #
11
- # To customize the GitHub URI prefix (e.g., for GitHub Enterprise
12
- # installations), set GitHub options in `~/.twigconfig`:
13
- #
14
- # github-uri-prefix: http://example-enterprise.github.com
15
- # github-api-uri-prefix: http://example-enterprise.github.com
16
- #
17
- # Options:
18
- #
19
- # `-b` or `--branch`: Opens the GitHub issue, if any, for the given branch.
20
- #
21
- # Subcommand for Twig: <http://rondevera.github.io/twig/>
22
- # Author: Ron DeVera <http://rondevera.com>
23
-
24
3
  require 'rubygems'
25
4
  require 'twig'
26
5
  require 'launchy'
27
6
 
7
+ def help_content
8
+ <<-HELP
9
+
10
+ twig-gh-open-issue
11
+ ==================
12
+
13
+ Opens a browser window for a branch's GitHub issue, if any.
14
+
15
+ Synopsis
16
+ --------
17
+
18
+ twig gh-open-issue [-b|--branch <branch>]
19
+
20
+ Description
21
+ -----------
22
+
23
+ Opens a browser window for the GitHub issue, if any, for the current branch.
24
+
25
+ To customize the GitHub URI prefix (e.g., for GitHub Enterprise
26
+ installations), set GitHub options in `~/.twigconfig`:
27
+
28
+ github-uri-prefix: http://example-enterprise.github.com
29
+ github-api-uri-prefix: http://example-enterprise.github.com
30
+
31
+ Options
32
+ -------
33
+
34
+ `-b` or `--branch`: Opens the GitHub issue, if any, for the given branch.
35
+
36
+ See also
37
+ --------
38
+
39
+ twig-gh-open
40
+ twig-gh-update
41
+
42
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
43
+ Author: Ron DeVera <http://rondevera.com>
44
+
45
+ HELP
46
+ end
47
+
48
+ args = ARGV.dup
49
+
50
+ if args.include?('--help')
51
+ puts help_content
52
+ exit
53
+ end
54
+
28
55
  Twig::GithubRepo.new do |gh_repo|
29
56
  twig = Twig.new(:read_options => true)
30
57
  target_branch_name = twig.target_branch_name
@@ -35,8 +62,9 @@ Twig::GithubRepo.new do |gh_repo|
35
62
  end
36
63
 
37
64
  gh_uri_prefix = twig.options[:github_uri_prefix]
38
- url = "#{gh_uri_prefix}/#{gh_repo.username}/#{gh_repo.repository}"
39
- url << "/issues/#{issue_id}"
65
+ url =
66
+ "#{gh_uri_prefix}/#{gh_repo.username}/#{gh_repo.repository}" \
67
+ "/issues/#{issue_id}"
40
68
 
41
69
  puts "GitHub issue URL: #{url}"
42
70
  Launchy.open(url) rescue nil
data/bin/twig-gh-update CHANGED
@@ -1,28 +1,54 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Synopsis:
4
- #
5
- # twig gh-update
6
- #
7
- # Description:
8
- #
9
- # Updates each branch with the latest issue status on GitHub.
10
- #
11
- # To customize the GitHub URI prefix (e.g., for GitHub Enterprise
12
- # installations), set GitHub options in `~/.twigconfig`:
13
- #
14
- # github-uri-prefix: http://example-enterprise.github.com
15
- # github-api-uri-prefix: http://example-enterprise.github.com
16
- #
17
- # Subcommand for Twig: <http://rondevera.github.io/twig/>
18
- # Author: Ron DeVera <http://rondevera.com>
19
-
20
- require File.join(File.dirname(__FILE__), '..', 'lib', 'twig')
21
3
  require 'rubygems'
4
+ require 'twig'
22
5
  require 'json'
23
6
  require 'net/https'
24
7
  require 'uri'
25
8
 
9
+ def help_content
10
+ <<-HELP
11
+
12
+ twig-gh-update
13
+ ==============
14
+
15
+ Updates each branch with the latest issue status on GitHub.
16
+
17
+ Synopsis
18
+ --------
19
+
20
+ twig gh-update
21
+
22
+ Description
23
+ -----------
24
+
25
+ Updates each branch with the latest issue status on GitHub.
26
+
27
+ To customize the GitHub URI prefix (e.g., for GitHub Enterprise
28
+ installations), set GitHub options in `~/.twigconfig`:
29
+
30
+ github-uri-prefix: http://example-enterprise.github.com
31
+ github-api-uri-prefix: http://example-enterprise.github.com
32
+
33
+ See also
34
+ --------
35
+
36
+ twig-gh-open
37
+ twig-gh-open-issue
38
+
39
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
40
+ Author: Ron DeVera <http://rondevera.com>
41
+
42
+ HELP
43
+ end
44
+
45
+ args = ARGV.dup
46
+
47
+ if args.include?('--help')
48
+ puts help_content
49
+ exit
50
+ end
51
+
26
52
  twig = Twig.new(:read_options => true)
27
53
 
28
54
  Twig::GithubRepo.new do |gh_repo|
@@ -39,7 +65,7 @@ Twig::GithubRepo.new do |gh_repo|
39
65
  ]
40
66
  user_agent = "Twig/#{Twig::VERSION} (for Git; <#{Twig::HOMEPAGE}>)"
41
67
 
42
- error = "\n\nERROR: Couldn't get open issues from GitHub." <<
68
+ error = "\n\nERROR: Couldn't get open issues from GitHub." \
43
69
  "\n- API endpoints: " << issues_uris.map { |uri| "<#{uri}>" }.join(', ')
44
70
 
45
71
  begin
@@ -62,7 +88,7 @@ Twig::GithubRepo.new do |gh_repo|
62
88
  abort error + "\n- Response: #{response.code}"
63
89
  end
64
90
  end
65
- rescue OpenSSL::SSL::SSLError => exception
91
+ rescue OpenSSL::SSL::SSLError
66
92
  abort error
67
93
  end
68
94
 
data/bin/twig-help CHANGED
@@ -1,8 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Your friendly neighborhood `twig --help` alias.
4
- #
5
- # Subcommand for Twig: <http://rondevera.github.io/twig/>
6
- # Author: Ron DeVera <http://rondevera.com>
3
+ def help_content
4
+ <<-HELP
7
5
 
8
- exec('twig --help')
6
+ twig-help
7
+ =========
8
+
9
+ Provides help for Twig and its subcommands.
10
+
11
+ Synopsis
12
+ --------
13
+
14
+ twig help [<subcommand>]
15
+
16
+ Description
17
+ -----------
18
+
19
+ Shows help content for Twig and for its built-in subcommands.
20
+
21
+ To make a custom subcommand work with this system (e.g.,
22
+ `twig help my-subcommand`), simply add `--help` support to the subcommand
23
+ (e.g., `twig my-subcommand --help`), and Twig will call it automatically.
24
+
25
+ Examples
26
+ --------
27
+
28
+ Show help content for Twig:
29
+
30
+ twig help
31
+
32
+ Show help content for a Twig subcommand, e.g., `twig-rebase`:
33
+
34
+ twig help rebase
35
+
36
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
37
+ Author: Ron DeVera <http://rondevera.com>
38
+
39
+ HELP
40
+ end
41
+
42
+ args = ARGV.dup
43
+
44
+ if args.include?('--help')
45
+ puts help_content
46
+ exit
47
+ end
48
+
49
+ subcommand = args[0] || ''
50
+
51
+ # If no subcommand was given, default to `twig --help`
52
+ exec("twig #{subcommand} --help")
data/bin/twig-init CHANGED
@@ -1,15 +1,48 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Synopsis:
4
- #
5
- # twig init
6
- #
7
- # Description:
8
- #
9
- # Runs all initialization commands. This is only needed once after installing
10
- # Twig, and affects all Git repositories.
11
- #
12
- # Subcommand for Twig: <http://rondevera.github.io/twig/>
13
- # Author: Ron DeVera <http://rondevera.com>
14
-
15
- exec('twig init-completion')
3
+ def help_content
4
+ <<-HELP
5
+
6
+ twig-init
7
+ =========
8
+
9
+ Runs all Twig setup commands.
10
+
11
+ Synopsis
12
+ --------
13
+
14
+ twig init
15
+
16
+ Description
17
+ -----------
18
+
19
+ Runs all setup commands. This is only needed once after installing Twig, and
20
+ affects all Git repositories.
21
+
22
+ See also
23
+ --------
24
+
25
+ twig-init-completion
26
+ twig-init-config
27
+
28
+ Subcommand for Twig: <http://rondevera.github.io/twig/>
29
+ Author: Ron DeVera <http://rondevera.com>
30
+
31
+ HELP
32
+ end
33
+
34
+ args = ARGV.dup
35
+
36
+ if args.include?('--help')
37
+ puts help_content
38
+ exit
39
+ end
40
+
41
+ commands = [
42
+ 'echo',
43
+ 'twig init-config',
44
+ 'twig init-completion',
45
+ 'echo "*** Twig is almost ready! Follow the steps above, ***"',
46
+ 'echo "*** then run \`twig\` or \`twig help\` to get started. ***"'
47
+ ]
48
+ exec commands.join(';')