Commit 368f89ea authored by Marius Rackwitz's avatar Marius Rackwitz

[Command] Move ProjectDirectory into dedicated file

parent b31abc36
......@@ -14,6 +14,9 @@ module Pod
end
class Command < CLAide::Command
require 'cocoapods/command/options/project_directory'
include Options
require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/lib'
require 'cocoapods/command/list'
......@@ -32,8 +35,6 @@ module Pod
self.description = 'CocoaPods, the Cocoa library package manager.'
self.plugin_prefixes = %w(claide cocoapods)
[Install, Update, Outdated, IPC::Podfile, IPC::Repl].each { |c| c.send(:include, ProjectDirectory) }
def self.options
[
['--silent', 'Show nothing'],
......
......@@ -37,6 +37,8 @@ module Pod
#-----------------------------------------------------------------------#
class Podfile < IPC
include ProjectDirectory
self.summary = 'Converts a Podfile to YAML'
self.description = 'Converts a Podfile to YAML and prints it to STDOUT.'
self.arguments = [
......@@ -123,6 +125,8 @@ module Pod
#-----------------------------------------------------------------------#
class Repl < IPC
include ProjectDirectory
END_OF_OUTPUT_SIGNAL = "\n\r"
self.summary = 'The repl listens to commands on standard input'
......
module Pod
class Command
module Options
# Provides support for commands to take a user-specified `project directory`
#
module ProjectDirectory
module Options
def options
[
['--project-directory=/project/dir/', 'The path to the root of the project directory'],
].concat(super)
end
end
def self.included(base)
base.extend(Options)
end
def initialize(argv)
if project_directory = argv.option('project-directory')
@project_directory = Pathname.new(project_directory).expand_path
end
config.installation_root = @project_directory
super
end
def validate!
super
if @project_directory && !@project_directory.directory?
raise Informative, "`#{@project_directory}` is not a valid directory."
end
end
end
end
end
end
module Pod
class Command
class Outdated < Command
include ProjectDirectory
self.summary = 'Show outdated project dependencies'
self.description = <<-DESC
......
module Pod
class Command
# Provides support for commands to take a user-specified `project directory`
#
module ProjectDirectory
module Options
def options
[
['--project-directory=/project/dir/', 'The path to the root of the project directory'],
].concat(super)
end
end
def self.included(base)
base.extend(Options)
end
def initialize(argv)
if project_directory = argv.option('project-directory')
@project_directory = Pathname.new(project_directory).expand_path
end
config.installation_root = @project_directory
super
end
def validate!
super
if @project_directory && !@project_directory.directory?
raise Informative,
"`#{@project_directory}` is not a valid directory."
end
end
end
#-------------------------------------------------------------------------#
class Install < Command
include ProjectDirectory
self.summary = 'Install project dependencies to Podfile.lock versions'
self.description = <<-DESC
......@@ -76,6 +44,8 @@ module Pod
#-------------------------------------------------------------------------#
class Update < Command
include ProjectDirectory
self.summary = 'Update outdated project dependencies and create new ' \
'Podfile.lock'
......
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