Skip to content

Instantly share code, notes, and snippets.

@munificent
Created January 30, 2014 00:12
Show Gist options
  • Save munificent/8700021 to your computer and use it in GitHub Desktop.
Save munificent/8700021 to your computer and use it in GitHub Desktop.
A new pub command?

I'm starting to work on a new pub command. I've got two goals for it.

Use case 1: Pre-populating your cache (bug #16265)

The first is that it can be used to install a package into your system cache. For example, maybe you're about to go off the grid and you want to make sure you have a bunch of stuff cached locally before you fall off the Internet. pub get does this implicitly, of course, but you may not have any packages that depend on the stuff you're downloading. You just want to pull it down.

Our specific use case is that we are starting to run tests of packages. Since hitting the network can fail, we'd like to do that separately from running pub get so that we can handle the failure more gracefully.

The idea is you could do:

$ pub ___ some_package -v "<=2.0.0"

Where ___ is the name of this command. That will find the latest version of some_package that matches <=2.0.0 and install it into your cache. You can call this command anywhere, you don't have to be in a package.

Use case 2: Making package binaries available from the command line (bug #7874)

Once that's in place, the next use case for this command is for working with packages that contain command line applications. Once you've used this command to pull down some package, it could then do some unspecified shenanigans to look in that package's bin directory and put the stuff in there on your PATH.

I will not be working on that functionality just yet. Right now, I'm only focused on use case 1, but I want to design the command in anticipation of use case 2. Here's where you come in. I'd like some feedback on what that command should be called.

Reclaiming pub install?

The command to pull down your dependencies used to be pub install before we renamed it to pub get. The old name still works now as an alias for get.

We can't come up with a better name for this "put stuff in my system cache and maybe add binaries to my PATH" command than install. So our proposal is to take that command back and make it not just be a synonym for get anymore. It would look something like:

# Download the latest version of "foo" from pub into my cache.
$ pub install foo

# Download foo 1.0.0 from pub into my cache.
$ pub install foo -v 1.0.0

# Install foo from the Git repo at some/git/path.
$ pub install -s git some/git/path

# Download all versions of foo matching that version constraint.
$ pub install foo -v ">1.0.0 <2.0.0" --all

I'm a little iffy on some of those arguments, but you get the idea. Thoughts?

@kevmoo
Copy link

kevmoo commented Jan 31, 2014

If you go w/ pub install make sure we have a full major release where install throws and points folks to get.

Force an unlearn before you teach something new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment