Skip to content

Commit

Permalink
Add version commmand
Browse files Browse the repository at this point in the history
All packages installed with brew have the version of the package in the
name of the parent folder. Whereas those installed from source have the
git tags present.

With that in mind, either the git tags or parent folder name is referenced to
print the release version used.

Relates: #159
  • Loading branch information
patdel0 committed Feb 6, 2023
1 parent c47589b commit 78187f1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Whippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function commands()
$this->command('migrate OLDPATH NEWPATH', 'Examines an existing wp-content directory and attempts to create an identical Whippet application.');
$this->command('dependencies SUBCOMMAND', 'Manage dependencies (themes, plugins)');
$this->command('deps SUBCOMMAND', 'Alias for dependencies');
$this->command('version', 'Prints whippet version');
}

public function plugins($plugin_command)
Expand Down Expand Up @@ -84,4 +85,18 @@ public function deps()
{
$this->dependencies();
}

public function version()
{
$whippetPath = dirname(__DIR__);
$installedWithBrew = strpos($whippetPath, 'opt/homebrew');

if ($installedWithBrew) {
$whippetVersion = basename($whippetPath);
} else {
$whippetVersion = substr(`git --git-dir $whippetPath/.git describe --tags`, 1, 5);
}

echo $whippetVersion . "\n";
}
};

0 comments on commit 78187f1

Please sign in to comment.