Commit 33262152 authored by Eloy Duran's avatar Eloy Duran

Work on the command help system.

parent 37f4f9bd
module Pod module Pod
class Command class Command
include Config::Mixin
autoload :Help, 'cocoa_pods/command/help'
autoload :Install, 'cocoa_pods/command/install' autoload :Install, 'cocoa_pods/command/install'
autoload :Repo, 'cocoa_pods/command/repo' autoload :Repo, 'cocoa_pods/command/repo'
autoload :Setup, 'cocoa_pods/command/setup' autoload :Setup, 'cocoa_pods/command/setup'
autoload :Spec, 'cocoa_pods/command/spec' autoload :Spec, 'cocoa_pods/command/spec'
class Help
def initialize(command_class, argv)
@command_class, @argv = command_class, argv
end
def run
puts @command_class.banner
puts
puts "Options"
puts "======="
puts
puts @command_class.options
end
end
def self.banner
"### Commands\n" +
"\n" +
" * setup\n" +
" * install\n" +
" * repo\n" +
" * spec"
end
def self.options
" --help Show help information\n" +
" --verbose Print more information while working"
end
def self.parse(*argv) def self.parse(*argv)
argv = argv.dup argv = argv.dup
command = case argv.shift show_help = argv.delete('--help')
when 'help' then Help Config.instance.verbose = !!argv.delete('--verbose')
command_class = case argv.shift
when 'install' then Install when 'install' then Install
when 'repo' then Repo when 'repo' then Repo
when 'setup' then Setup when 'setup' then Setup
when 'spec' then Spec when 'spec' then Spec
end end
command.new(*argv)
if show_help || command_class.nil?
Help.new(command_class || self, argv)
else
command_class.new(*argv)
end
end end
include Config::Mixin
def initialize(*argv) def initialize(*argv)
raise ArgumentError, "unknown argument(s): #{argv.join(', ')}" unless argv.empty? raise ArgumentError, "unknown argument(s): #{argv.join(', ')}" unless argv.empty?
end end
......
module Pod
class Command
class Help < Command
def run
puts %{
### Setup
$ pod help setup
pod setup
Creates a directory at `~/.cocoa-pods' which will hold your spec-repos.
This is where it will create a clone of the public `master' spec-repo.
### Managing PodSpec files
$ pod help spec
pod spec create NAME
Creates a directory for your new pod, named `NAME', with a default
directory structure and accompanying `NAME.podspec'.
pod spec init NAME
Creates a PodSpec, in the current working dir, called `NAME.podspec'.
Use this for existing libraries.
pod spec lint NAME
Validates `NAME.podspec' from a local spec-repo. In case `NAME' is
omitted, it defaults to the PodSpec in the current working dir.
pod spec push REMOTE
Validates `NAME.podspec' in the current working dir, copies it to the
local clone of the `REMOTE' spec-repo, and pushes it to the `REMOTE'
spec-repo. In case `REMOTE' is omitted, it defaults to `master'.
### Managing spec-repos
$ pod help repo
pod repo add NAME URL
Clones `URL' in the local spec-repos directory at `~/.cocoa-pods'. The
remote can later be referred to by `NAME'.
pod repo update NAME
Updates the local clone of the spec-repo `NAME'.
pod repo change NAME URL
Changes the git remote of local spec-repo `NAME' to `URL'.
pod repo cd NAME
Changes the current working dir to the local spec-repo `NAME'.
}
end
end
end
end
module Pod module Pod
class Command class Command
class Install < Command class Install < Command
def self.banner
'TODO'
end
def self.options
" --no-clean Leave SCM dirs like `.git' and `.svn' in tact after downloading\n" +
super
end
def initialize(*argv) def initialize(*argv)
config.clean = !argv.delete('--no-clean')
if podspec = argv.shift if podspec = argv.shift
@podspec = Pathname.new(podspec) @podspec = Pathname.new(podspec)
end end
......
...@@ -4,6 +4,25 @@ require 'fileutils' ...@@ -4,6 +4,25 @@ require 'fileutils'
module Pod module Pod
class Command class Command
class Repo < Command class Repo < Command
def self.banner
%{### Managing spec-repos
$ pod help repo
pod repo add NAME URL
Clones `URL' in the local spec-repos directory at `~/.cocoa-pods'. The
remote can later be referred to by `NAME'.
pod repo update NAME
Updates the local clone of the spec-repo `NAME'.
pod repo change NAME URL
Changes the git remote of local spec-repo `NAME' to `URL'.
pod repo cd NAME
Changes the current working dir to the local spec-repo `NAME'.}
end
include Executioner include Executioner
executable :git executable :git
......
...@@ -3,6 +3,16 @@ require 'cocoa_pods/command/repo' ...@@ -3,6 +3,16 @@ require 'cocoa_pods/command/repo'
module Pod module Pod
class Command class Command
class Setup < Command class Setup < Command
def self.banner
%{### Setup
$ pod help setup
pod setup
Creates a directory at `~/.cocoa-pods' which will hold your spec-repos.
This is where it will create a clone of the public `master' spec-repo.}
end
def master_repo_url def master_repo_url
'git://github.com/alloy/cocoa-pod-specs.git' 'git://github.com/alloy/cocoa-pod-specs.git'
end end
......
module Pod module Pod
class Command class Command
class Spec < Command class Spec < Command
def self.banner
%{### Managing PodSpec files
$ pod help spec
pod spec create NAME
Creates a directory for your new pod, named `NAME', with a default
directory structure and accompanying `NAME.podspec'.
pod spec init NAME
Creates a PodSpec, in the current working dir, called `NAME.podspec'.
Use this for existing libraries.
pod spec lint NAME
Validates `NAME.podspec' from a local spec-repo. In case `NAME' is
omitted, it defaults to the PodSpec in the current working dir.
pod spec push REMOTE
Validates `NAME.podspec' in the current working dir, copies it to the
local clone of the `REMOTE' spec-repo, and pushes it to the `REMOTE'
spec-repo. In case `REMOTE' is omitted, it defaults to `master'.}
end
end end
end end
end end
...@@ -10,11 +10,12 @@ module Pod ...@@ -10,11 +10,12 @@ module Pod
@instance = instance @instance = instance
end end
attr_accessor :repos_dir, :clean attr_accessor :repos_dir, :clean, :verbose
def initialize def initialize
@repos_dir = Pathname.new(File.expand_path("~/.cocoa-pods")) @repos_dir = Pathname.new(File.expand_path("~/.cocoa-pods"))
@clean = true @clean = true
@verbose = false
end end
def project_root def project_root
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment