From 2385c3f80766f1ca776a0dd4abd8727ef78354f2 Mon Sep 17 00:00:00 2001 From: Ritesh Date: Fri, 26 Aug 2022 11:38:18 +0530 Subject: [PATCH] add: version flag --- .gitignore | 4 +++- cmd/root.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f47b9cc..590ff6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .vscode/ .DS_Store bin/** -!bin/.gitkeep \ No newline at end of file +!bin/.gitkeep +dist/ +.* \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index 529e30a..3e335fe 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,6 +5,7 @@ Copyright © 2022 NAME HERE package cmd import ( + "fmt" "os" app "github.com/dunstorm/pm2-go/app" @@ -26,6 +27,10 @@ It allows you to keep applications alive forever, to reload them without downtim master.SpawnDaemon() return } + if version, _ := cmd.PersistentFlags().GetBool("version"); version { + fmt.Println("0.1.1") + return + } cmd.Usage() }, } @@ -50,5 +55,6 @@ func init() { // when this action is called directly. rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") rootCmd.PersistentFlags().BoolP("daemon", "d", false, "Run as daemon") + rootCmd.PersistentFlags().BoolP("version", "v", false, "Print pm2 version") logsCmd.PersistentFlags().IntP("lines", "l", 15, "Number of lines to tail") }