-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd/scripts/ins_oxs_cz): Create wrapper around curl to ins.oxs.cz
- Loading branch information
1 parent
8be9cdb
commit 7f093e5
Showing
2 changed files
with
44 additions
and
0 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,43 @@ | ||
package ins_oxs_cz | ||
|
||
import ( | ||
"fmt" | ||
|
||
parent_cmd "github.com/sikalabs/slu/cmd/scripts" | ||
"github.com/sikalabs/slu/utils/sh_utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var FlagDry bool | ||
|
||
var Cmd = &cobra.Command{ | ||
Use: "ins-oxs-cz <script>", | ||
Aliases: []string{"ins"}, | ||
Short: "Run script from ins.oxs.cz", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(c *cobra.Command, args []string) { | ||
name := args[0] | ||
sh("curl -fsSL https://ins.oxs.cz/"+name+".sh | sh", FlagDry) | ||
}, | ||
} | ||
|
||
func init() { | ||
parent_cmd.Cmd.AddCommand(Cmd) | ||
Cmd.Flags().BoolVar( | ||
&FlagDry, | ||
"dry-run", | ||
false, | ||
"Dry run", | ||
) | ||
} | ||
|
||
func sh(script string, dry bool) { | ||
if dry { | ||
fmt.Println(script) | ||
return | ||
} | ||
err := sh_utils.ExecShOutDir("", script) | ||
if err != nil { | ||
sh_utils.HandleError(err) | ||
} | ||
} |