class SocialSnippet::CommandLine::SSpm::SubCommands::PublishCommand

Public Instance Methods

define_options() click to toggle source
# File lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb, line 29
def define_options
end
desc() click to toggle source
# File lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb, line 25
def desc
  "Publish a repository to the registry system"
end
run() click to toggle source
# 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
      core.api.add_url repo_url
    elsif has_next_token? # {repo_owner_id} {repo_id}
      owner_id  = repo_url
      repo_id   = next_token
      core.api.add_url "https://github.com/#{owner_id}/#{repo_id}.git"
    else
      help
    end
  else
    help
  end
end
usage() click to toggle source
# 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