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

[Command] Move ProjectDirectory into dedicated file

parent b31abc36
...@@ -14,6 +14,9 @@ module Pod ...@@ -14,6 +14,9 @@ module Pod
end end
class Command < CLAide::Command class Command < CLAide::Command
require 'cocoapods/command/options/project_directory'
include Options
require 'cocoapods/command/inter_process_communication' require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/lib' require 'cocoapods/command/lib'
require 'cocoapods/command/list' require 'cocoapods/command/list'
...@@ -32,8 +35,6 @@ module Pod ...@@ -32,8 +35,6 @@ module Pod
self.description = 'CocoaPods, the Cocoa library package manager.' self.description = 'CocoaPods, the Cocoa library package manager.'
self.plugin_prefixes = %w(claide cocoapods) self.plugin_prefixes = %w(claide cocoapods)
[Install, Update, Outdated, IPC::Podfile, IPC::Repl].each { |c| c.send(:include, ProjectDirectory) }
def self.options def self.options
[ [
['--silent', 'Show nothing'], ['--silent', 'Show nothing'],
......
...@@ -37,6 +37,8 @@ module Pod ...@@ -37,6 +37,8 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class Podfile < IPC class Podfile < IPC
include ProjectDirectory
self.summary = 'Converts a Podfile to YAML' self.summary = 'Converts a Podfile to YAML'
self.description = 'Converts a Podfile to YAML and prints it to STDOUT.' self.description = 'Converts a Podfile to YAML and prints it to STDOUT.'
self.arguments = [ self.arguments = [
...@@ -123,6 +125,8 @@ module Pod ...@@ -123,6 +125,8 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class Repl < IPC class Repl < IPC
include ProjectDirectory
END_OF_OUTPUT_SIGNAL = "\n\r" END_OF_OUTPUT_SIGNAL = "\n\r"
self.summary = 'The repl listens to commands on standard input' 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 module Pod
class Command class Command
class Outdated < Command class Outdated < Command
include ProjectDirectory
self.summary = 'Show outdated project dependencies' self.summary = 'Show outdated project dependencies'
self.description = <<-DESC self.description = <<-DESC
......
module Pod module Pod
class Command 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 class Install < Command
include ProjectDirectory
self.summary = 'Install project dependencies to Podfile.lock versions' self.summary = 'Install project dependencies to Podfile.lock versions'
self.description = <<-DESC self.description = <<-DESC
...@@ -76,6 +44,8 @@ module Pod ...@@ -76,6 +44,8 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
class Update < Command class Update < Command
include ProjectDirectory
self.summary = 'Update outdated project dependencies and create new ' \ self.summary = 'Update outdated project dependencies and create new ' \
'Podfile.lock' '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