-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd: Add gen command to generate alias scripts
Closes #22
- Loading branch information
Showing
20 changed files
with
343 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright © 2023 Joe Mooring <joe.mooring@veriphor.com> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// aliasCmd represents the alias command | ||
var aliasCmd = &cobra.Command{ | ||
Use: "alias", | ||
Short: "Generate the alias script for the specified shell", | ||
Long: `Generate the alias script for the specified shell. | ||
See each sub-command's help for details on how to use the generated script.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmd.Help() | ||
}, | ||
} | ||
|
||
func init() { | ||
genCmd.AddCommand(aliasCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Hugo Version Manager: override path to the hugo executable. | ||
hugo() { | ||
hvm_show_status=true | ||
if [ -f ".hvm" ]; then | ||
if ! hugo_bin=$(hvm status --printExecPath); then | ||
return 1 | ||
else | ||
if [ "${hvm_show_status}" == true ]; then | ||
>&2 printf "Hugo version management is enabled in this directory.\\n" | ||
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n" | ||
fi | ||
fi | ||
else | ||
if ! hugo_bin=$(which hugo); then | ||
>&2 printf "Command not found.\\n" | ||
return 1 | ||
fi | ||
fi | ||
"${hugo_bin}" "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Hugo Version Manager: override path to the hugo executable. | ||
hugo() { | ||
hvm_show_status=true | ||
if [ -f ".hvm" ]; then | ||
if ! hugo_bin=$(hvm status --printExecPath); then | ||
return 1 | ||
else | ||
if [ "${hvm_show_status}" == true ]; then | ||
>&2 printf "Hugo version management is enabled in this directory.\\n" | ||
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n" | ||
fi | ||
fi | ||
else | ||
if ! hugo_bin=$(which hugo); then | ||
>&2 printf "Command not found.\\n" | ||
return 1 | ||
fi | ||
fi | ||
"${hugo_bin}" "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Hugo Version Manager: override path to the hugo executable. | ||
|
||
TBD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Hugo Version Manager: override path to the hugo executable. | ||
hugo() { | ||
hvm_show_status=true | ||
if [ -f ".hvm" ]; then | ||
if ! hugo_bin=$(hvm status --printExecPath); then | ||
return 1 | ||
else | ||
if [ "${hvm_show_status}" == true ]; then | ||
>&2 printf "Hugo version management is enabled in this directory.\\n" | ||
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n" | ||
fi | ||
fi | ||
else | ||
if ! hugo_bin=$(which hugo); then | ||
>&2 printf "Command not found.\\n" | ||
return 1 | ||
fi | ||
fi | ||
"${hugo_bin}" "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright © 2023 Joe Mooring <joe.mooring@veriphor.com> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
//go:embed alias_scripts/bash.sh | ||
var bashScript string | ||
|
||
// bashCmd represents the bash command | ||
var bashCmd = &cobra.Command{ | ||
Use: "bash", | ||
Short: "Generate the alias script for bash", | ||
Long: `Generate the alias script for the bash shell. | ||
Add the output from this command to $HOME/.bashrc or $HOME/.bash_aliases. | ||
Open a new shell to activate the alias.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Print(bashScript) | ||
}, | ||
} | ||
|
||
func init() { | ||
aliasCmd.AddCommand(bashCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright © 2023 Joe Mooring <joe.mooring@veriphor.com> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
//go:embed alias_scripts/fish.sh | ||
var fishScript string | ||
|
||
// fishCmd represents the fish command | ||
var fishCmd = &cobra.Command{ | ||
Use: "fish", | ||
Short: "Generate the alias script for fish", | ||
Long: `Generate the alias script for the fish shell. | ||
Add the output from this command to $HOME/.config/fish/config.fish. | ||
Open a new shell to activate the alias.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Print(fishScript) | ||
}, | ||
} | ||
|
||
func init() { | ||
aliasCmd.AddCommand(fishCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
Copyright © 2023 Joe Mooring <joe.mooring@veriphor.com> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// genCmd represents the gen command | ||
var genCmd = &cobra.Command{ | ||
Use: "gen", | ||
Short: "Generate various files", | ||
Long: "Generate various files.", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmd.Help() | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(genCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright © 2023 Joe Mooring <joe.mooring@veriphor.com> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
//go:embed alias_scripts/powershell.ps1 | ||
var powershellScript string | ||
|
||
// powershellCmd represents the powershell command | ||
var powershellCmd = &cobra.Command{ | ||
Use: "powershell", | ||
Short: "Generate the alias script for zsh", | ||
Long: `Generate the alias script for powershell.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Print(powershellScript) | ||
}, | ||
} | ||
|
||
func init() { | ||
aliasCmd.AddCommand(powershellCmd) | ||
} |
Oops, something went wrong.