From af408269cfbe58a556dba90b61afe8eba5315acf Mon Sep 17 00:00:00 2001 From: future Date: Thu, 12 Dec 2013 12:31:57 +0100 Subject: [PATCH 1/7] Make caskroom configurable via command line argument --- lib/cask/cli.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/cask/cli.rb b/lib/cask/cli.rb index 7778d3dd8..ad189779e 100644 --- a/lib/cask/cli.rb +++ b/lib/cask/cli.rb @@ -59,6 +59,9 @@ class Cask::CLI def self.parser @parser ||= OptionParser.new do |opts| + opts.on("--caskroom=MANDATORY") do |v| + Cask.caskroom = Pathname(v).expand_path + end opts.on("--appdir=MANDATORY") do |v| Cask.appdir = Pathname(v).expand_path end From df539b33314de4881c5a45e182673ab9537997dc Mon Sep 17 00:00:00 2001 From: future Date: Thu, 12 Dec 2013 14:14:28 +0100 Subject: [PATCH 2/7] Clearer instructions for options --- USAGE.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index 7b684782d..fd5f23481 100644 --- a/USAGE.md +++ b/USAGE.md @@ -68,7 +68,10 @@ This will both uninstall and unlink the Cask. ## Options -You can set options on the command-line and/or using the `HOMEBREW_CASK_OPTS` environment variable, e.g. (again, using google-chrome): +You can set [a number of options](https://github.com/phinze/homebrew-cask/blob/master/lib/cask/cli.rb#L60) on the command-line and/or using the `HOMEBREW_CASK_OPTS` environment variable. +Among others you can change the location of where applications will be installed (if `/opt/homebrew-cask/Caskroom` doesn't work well for you). + +This is an example of how to apply an option (again, using google-chrome): ```bash # This probably should happen in your ~/.{ba|z}shrc From 738479174c1910b8dacd52d9485b18367852875c Mon Sep 17 00:00:00 2001 From: future Date: Thu, 12 Dec 2013 17:48:46 +0100 Subject: [PATCH 3/7] Added test for custom --caskroom argument --- test/cask/cli_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/cask/cli_test.rb b/test/cask/cli_test.rb index a67210d2d..813126a99 100644 --- a/test/cask/cli_test.rb +++ b/test/cask/cli_test.rb @@ -74,6 +74,28 @@ describe Cask::CLI do custom_qlplugin_dir.directory?.must_equal true end + it "respects the env variable when choosing what caskroom to create, not touching the default caskroom" do + default_caskroom_dir = Cask.caskroom + default_caskroom_dir.rmdir + custom_caskroom_dir = Pathname(Dir.mktmpdir('custom_caskroom_dir')) + custom_caskroom_dir.rmdir + + default_caskroom_dir.directory?.must_equal false + custom_caskroom_dir.directory?.must_equal false + + begin + ENV['HOMEBREW_CASK_OPTS'] = "--caskroom=#{custom_caskroom_dir}" + shutup { + Cask::CLI.process('list') + } + ensure + ENV.delete 'HOMEBREW_CASK_OPTS' + end + + default_caskroom_dir.directory?.must_equal false + custom_caskroom_dir.directory?.must_equal true + end + it "exits with a status of 1 when something goes wrong" do Cask::CLI.expects(:exit).with(1) Cask::CLI.expects(:lookup_command).raises(CaskError) From bb2e3ab18749e1b2051bb686b6b4d54604606ba7 Mon Sep 17 00:00:00 2001 From: future Date: Sat, 14 Dec 2013 09:51:30 +0100 Subject: [PATCH 4/7] Improved the name of a test --- test/cask/cli_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cask/cli_test.rb b/test/cask/cli_test.rb index 813126a99..eb4b6524f 100644 --- a/test/cask/cli_test.rb +++ b/test/cask/cli_test.rb @@ -74,7 +74,7 @@ describe Cask::CLI do custom_qlplugin_dir.directory?.must_equal true end - it "respects the env variable when choosing what caskroom to create, not touching the default caskroom" do + it "respects the ENV variable when choosing a non-default Caskroom location" do default_caskroom_dir = Cask.caskroom default_caskroom_dir.rmdir custom_caskroom_dir = Pathname(Dir.mktmpdir('custom_caskroom_dir')) From 3ea8a8dccc3af547279fb25d6e3dafd1cc125a4c Mon Sep 17 00:00:00 2001 From: future Date: Sat, 14 Dec 2013 10:07:26 +0100 Subject: [PATCH 5/7] First shot at a better CLI argument documentation --- USAGE.md | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/USAGE.md b/USAGE.md index fd5f23481..197e237e4 100644 --- a/USAGE.md +++ b/USAGE.md @@ -68,19 +68,34 @@ This will both uninstall and unlink the Cask. ## Options -You can set [a number of options](https://github.com/phinze/homebrew-cask/blob/master/lib/cask/cli.rb#L60) on the command-line and/or using the `HOMEBREW_CASK_OPTS` environment variable. -Among others you can change the location of where applications will be installed (if `/opt/homebrew-cask/Caskroom` doesn't work well for you). +You can provide a number of options to the `brew cask` command to modify the default +installation locations. -This is an example of how to apply an option (again, using google-chrome): +* `--caskroom=/custom/path` determines where the actual applications will be located. +Default is `/opt/homebrew-cask/Caskroom` +* `--appdir=/custom/path/Applications` changes the path where the symlinks to the applications +will be generated. This is commonly used to create the links in the root Applications directory +by specifying `--appdir=/Applications`. Default is `~/Applications`. +* `--prefpanedir=/custom/path` changes the path for PreferencePane symlinks. +Default is `~/Library/PreferencePanes` +* `--qlplugindir=/custom/path` changes the path for Quicklook Plugin symlinks. +Default is `~/Library/QuickLook` +* `--widgetdir=/custom/path` changes the path for Dashboard Widget symlinks. +Default is `~/Library/Widgets` +* `--fontdir=/custom/path` changes the path for Fonts symlinks. +Default is `~/Library/Fonts` + +To make these changes permanent, you might want to add the following line to your `.bash_profile` or `.zshenv` ```bash -# This probably should happen in your ~/.{ba|z}shrc -$ export HOMEBREW_CASK_OPTS="--appdir=/Applications" +export HOMEBREW_CASK_OPTS="--appdir=/Applications --caskroom=/etc/Caskroom" +``` -# Installs app links to /Applications -$ brew cask install google-chrome +Note that you still can override the environment variable `HOMEBREW_CASK_OPTS` by explicitly providing +the options in the command line: -# Trumps the ENV and installs app links to ~/Applications +```bash +# Will force the Chrome app to be linked to ~/Applications $ brew cask install --appdir="~/Applications" google-chrome ``` From 51128842b6abca8485f2ca59ff87209505bba69f Mon Sep 17 00:00:00 2001 From: future Date: Sat, 14 Dec 2013 10:10:50 +0100 Subject: [PATCH 6/7] Minor USAGE tweaks --- USAGE.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/USAGE.md b/USAGE.md index 197e237e4..9e766be02 100644 --- a/USAGE.md +++ b/USAGE.md @@ -71,31 +71,33 @@ This will both uninstall and unlink the Cask. You can provide a number of options to the `brew cask` command to modify the default installation locations. -* `--caskroom=/custom/path` determines where the actual applications will be located. +* `--caskroom=/my/path` determines where the actual applications will be located. Default is `/opt/homebrew-cask/Caskroom` -* `--appdir=/custom/path/Applications` changes the path where the symlinks to the applications -will be generated. This is commonly used to create the links in the root Applications directory -by specifying `--appdir=/Applications`. Default is `~/Applications`. -* `--prefpanedir=/custom/path` changes the path for PreferencePane symlinks. +* `--appdir=/my/path` changes the path where the symlinks to the applications (above) +will be generated. This is commonly used to create the links in the _root_ Applications directory +instead of the _home_ Applications directory by specifying `--appdir=/Applications`. Default is `~/Applications`. +* `--prefpanedir=/my/path` changes the path for PreferencePane symlinks. Default is `~/Library/PreferencePanes` -* `--qlplugindir=/custom/path` changes the path for Quicklook Plugin symlinks. +* `--qlplugindir=/my/path` changes the path for Quicklook Plugin symlinks. Default is `~/Library/QuickLook` -* `--widgetdir=/custom/path` changes the path for Dashboard Widget symlinks. +* `--widgetdir=/my/path` changes the path for Dashboard Widget symlinks. Default is `~/Library/Widgets` -* `--fontdir=/custom/path` changes the path for Fonts symlinks. +* `--fontdir=/my/path` changes the path for Fonts symlinks. Default is `~/Library/Fonts` -To make these changes permanent, you might want to add the following line to your `.bash_profile` or `.zshenv` +To make these changes permanent, you might want to add the following line to your `.bash_profile` or `.zshenv`: ```bash +# Specify your defaults in this environment variable export HOMEBREW_CASK_OPTS="--appdir=/Applications --caskroom=/etc/Caskroom" ``` -Note that you still can override the environment variable `HOMEBREW_CASK_OPTS` by explicitly providing +Note that you still can override the environment variable `HOMEBREW_CASK_OPTS` by _explicitly_ providing the options in the command line: ```bash # Will force the Chrome app to be linked to ~/Applications +# even though HOMEBREW_CASK_OPTS specified /Applications $ brew cask install --appdir="~/Applications" google-chrome ``` From e7d98677fea20e5433cbb493b9d33f484c06750f Mon Sep 17 00:00:00 2001 From: future Date: Sat, 14 Dec 2013 10:13:06 +0100 Subject: [PATCH 7/7] Added inline comment on option parser so that people won't forget about the documentation --- lib/cask/cli.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cask/cli.rb b/lib/cask/cli.rb index ad189779e..1031d1dfb 100644 --- a/lib/cask/cli.rb +++ b/lib/cask/cli.rb @@ -58,6 +58,7 @@ class Cask::CLI end def self.parser + # If you modify these arguments, please update USAGE.md @parser ||= OptionParser.new do |opts| opts.on("--caskroom=MANDATORY") do |v| Cask.caskroom = Pathname(v).expand_path