Skip to content

Commit

Permalink
Merge pull request #18 from ashur/release/0.7.0
Browse files Browse the repository at this point in the history
release/0.7.0
  • Loading branch information
ashur authored Nov 14, 2016
2 parents ab82080 + 87bd42c commit 26ebea8
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 26 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

All notable changes to Pug will be documented in this file (beginning with v0.5 😅).

## [0.6.0] - 2015-08-10
## [0.7.0] - 2017-11-14
### Added
- `pug install`

## [0.6.0] - 2016-08-10
### Added
- Namespaces
- Command support for namespaces (aka groups): enable, disable, remove, update
Expand Down
45 changes: 21 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,30 @@ One command is all you need to update local repositories and their submodules. I

## Installation

First, clone this repository:

```
$ cd ~/tools
$ git clone --recursive https://github.com/ashur/pug.git
```

> 🎉 **New in v0.7**
Next, run the `install` command and include a directory that's already on your `$PATH`:

```
$ pug/bin/pug install /usr/local/bin
Linked to '/usr/local/bin/pug'
```

This will symlink the `pug` executable, letting you run `pug` from anywhere on the command line:

```
$ cd ~/Desktop/
$ pug --version
pug version 0.7.0
```

### Requirements

Pug requires PHP 5.4 or greater
Expand All @@ -42,34 +62,11 @@ $ pug up
>
> ```
> $ pug --version
> pug version 0.5.0
> pug version 0.7.0
> ```
>
> Nice. 😁
### Extra Credit
Let's say you cloned Pug to a local directory `~/tools`:
```
$ cd ~/tools
$ git clone --recursive https://github.com/ashur/pug.git
```
You'll probably want to symlink the Pug executable to a directory already on your `$PATH`:
```
$ ln -s ~/tools/pug/bin/pug /usr/local/bin/pug
```
This lets you run `pug` commands from anywhere on the command line, not just from inside the Pug repository folder.
Alternatively, you can add the repository's `bin` folder to your environment `$PATH`. For example:
```
export PATH=$PATH:$HOME/tools/pug/bin
```
## Basics
Expand Down
51 changes: 51 additions & 0 deletions lib/commands/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

use Huxtable\CLI\Command;
use Huxtable\Core\File;

/**
* @name install
* @description Symlink 'pug' to a convenient path
* @usage install <dir>
*/
$command = new Command( 'install', 'Symlink \'pug\' to a convenient path', function( $dir )
{
$pathSource = dirname( dirname( __DIR__ ) ) . '/bin/pug';

try
{
$destinationDirectory = new File\Directory( $dir );

if( !$destinationDirectory->exists() )
{
throw new \Exception( "Invalid location: '{$dir}' does not exist" );
}
}
catch( \Exception $e )
{
throw new Command\CommandInvokedException( $e->getMessage(), 1 );
}

if( !$destinationDirectory->isWritable() )
{
throw new Command\CommandInvokedException( "Invalid location: You do not have permission to write to '{$destinationDirectory}'" );
}

$target = $destinationDirectory->child( 'pug' );
$source = new File\File( $pathSource );

if( !$source->exists() )
{
throw new Command\CommandInvokedException( "Invalid source: '{$source}' not found", 1 );
}

if( $target->exists() || is_link( $target->getPathname() ) )
{
throw new Command\CommandInvokedException( "Invalid target: '{$target}' already exists", 1 );
}

symlink( $source, $target );
echo "Linked to '{$target}'" . PHP_EOL;
});

return $command;
2 changes: 1 addition & 1 deletion lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/*
* Application version
*/
'version' => '0.6.0',
'version' => '0.7.0',

/*
* PHP minimum version
Expand Down

0 comments on commit 26ebea8

Please sign in to comment.