Class: SocialSnippet::CommandLine::SSpm::SubCommands::PublishCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #input_stream, #opt_parser, #options, #output_stream, #streams, #tokens

Instance Method Summary collapse

Methods inherited from Command

#define_option, #init, #initialize, #social_snippet

Constructor Details

This class inherits a constructor from SocialSnippet::CommandLine::Command

Instance Method Details

#define_optionsObject


29
30
# File 'lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb', line 29

def define_options
end

#descObject


25
26
27
# File 'lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb', line 25

def desc
  "Publish a repository to the registry system"
end

#runObject


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb', line 32

def run
  if has_next_token?
    repo_url = next_token
    if /^(git|http|https)\:\/\// === repo_url # url
      social_snippet.api.add_url repo_url
    elsif has_next_token? # {repo_owner_id} {repo_id}
      owner_id  = repo_url
      repo_id   = next_token
      social_snippet.api.add_url "https://github.com/#{owner_id}/#{repo_id}.git"
    else
      help
    end
  else
    help
  end
end

#usageObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb', line 5

def usage
  <<EOF
Usage:
- sspm publish [options] [--] <repo-url>
- sspm publish [options] [--] <owner-id> <repo-id>
(published as "https://github.com/{owner-id}/{repo-id}.git")

Example:
$ sspm publish https://github.com/user/repo
-> published as the name written in snippet.json

[another method]
$ sspm publish user repo

Note:
- Currently the registry system supported the GitHub repositories only.

EOF
end