Skip to content
This repository was archived by the owner on May 24, 2025. It is now read-only.

Commit 26ebea8

Browse files
authored
Merge pull request #18 from ashur/release/0.7.0
release/0.7.0
2 parents ab82080 + 87bd42c commit 26ebea8

File tree

4 files changed

+78
-26
lines changed

4 files changed

+78
-26
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

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

5-
## [0.6.0] - 2015-08-10
5+
## [0.7.0] - 2017-11-14
6+
### Added
7+
- `pug install`
8+
9+
## [0.6.0] - 2016-08-10
610
### Added
711
- Namespaces
812
- Command support for namespaces (aka groups): enable, disable, remove, update

README.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,30 @@ One command is all you need to update local repositories and their submodules. I
1313

1414
## Installation
1515

16+
First, clone this repository:
17+
1618
```
19+
$ cd ~/tools
1720
$ git clone --recursive https://github.com/ashur/pug.git
1821
```
1922

23+
> 🎉 **New in v0.7**
24+
25+
Next, run the `install` command and include a directory that's already on your `$PATH`:
26+
27+
```
28+
$ pug/bin/pug install /usr/local/bin
29+
Linked to '/usr/local/bin/pug'
30+
```
31+
32+
This will symlink the `pug` executable, letting you run `pug` from anywhere on the command line:
33+
34+
```
35+
$ cd ~/Desktop/
36+
$ pug --version
37+
pug version 0.7.0
38+
```
39+
2040
### Requirements
2141

2242
Pug requires PHP 5.4 or greater
@@ -42,34 +62,11 @@ $ pug up
4262
>
4363
> ```
4464
> $ pug --version
45-
> pug version 0.5.0
65+
> pug version 0.7.0
4666
> ```
4767
>
4868
> Nice. 😁
4969
50-
### Extra Credit
51-
52-
Let's say you cloned Pug to a local directory `~/tools`:
53-
54-
```
55-
$ cd ~/tools
56-
$ git clone --recursive https://github.com/ashur/pug.git
57-
```
58-
59-
You'll probably want to symlink the Pug executable to a directory already on your `$PATH`:
60-
61-
```
62-
$ ln -s ~/tools/pug/bin/pug /usr/local/bin/pug
63-
```
64-
65-
This lets you run `pug` commands from anywhere on the command line, not just from inside the Pug repository folder.
66-
67-
Alternatively, you can add the repository's `bin` folder to your environment `$PATH`. For example:
68-
69-
```
70-
export PATH=$PATH:$HOME/tools/pug/bin
71-
```
72-
7370
7471
## Basics
7572

lib/commands/install.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
use Huxtable\CLI\Command;
4+
use Huxtable\Core\File;
5+
6+
/**
7+
* @name install
8+
* @description Symlink 'pug' to a convenient path
9+
* @usage install <dir>
10+
*/
11+
$command = new Command( 'install', 'Symlink \'pug\' to a convenient path', function( $dir )
12+
{
13+
$pathSource = dirname( dirname( __DIR__ ) ) . '/bin/pug';
14+
15+
try
16+
{
17+
$destinationDirectory = new File\Directory( $dir );
18+
19+
if( !$destinationDirectory->exists() )
20+
{
21+
throw new \Exception( "Invalid location: '{$dir}' does not exist" );
22+
}
23+
}
24+
catch( \Exception $e )
25+
{
26+
throw new Command\CommandInvokedException( $e->getMessage(), 1 );
27+
}
28+
29+
if( !$destinationDirectory->isWritable() )
30+
{
31+
throw new Command\CommandInvokedException( "Invalid location: You do not have permission to write to '{$destinationDirectory}'" );
32+
}
33+
34+
$target = $destinationDirectory->child( 'pug' );
35+
$source = new File\File( $pathSource );
36+
37+
if( !$source->exists() )
38+
{
39+
throw new Command\CommandInvokedException( "Invalid source: '{$source}' not found", 1 );
40+
}
41+
42+
if( $target->exists() || is_link( $target->getPathname() ) )
43+
{
44+
throw new Command\CommandInvokedException( "Invalid target: '{$target}' already exists", 1 );
45+
}
46+
47+
symlink( $source, $target );
48+
echo "Linked to '{$target}'" . PHP_EOL;
49+
});
50+
51+
return $command;

lib/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/*
1010
* Application version
1111
*/
12-
'version' => '0.6.0',
12+
'version' => '0.7.0',
1313

1414
/*
1515
* PHP minimum version

0 commit comments

Comments
 (0)