-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ea9b02
commit bcc787c
Showing
11 changed files
with
327 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Quick Script Runner: A quick and easy way to run gists | ||
* Copyright © 2020 Brett Bender | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package cmd | ||
|
||
import "github.com/spf13/viper" | ||
|
||
func SetGists() { | ||
/* Repository of different user's gists! | ||
* If you'd like your personal gist here, create a pull request, adding it to this list, | ||
* and to gists.md | ||
*/ | ||
|
||
|
||
//// "apollo": GreatGodApollo (Author) | ||
viper.Set("apollo", map[string]string{"gist": "00d91bfb540b8bc0169606b4d4f740a3"}) | ||
|
||
//// "324luke": 324Luke (Contributor) | ||
viper.Set("324luke", map[string]string{"gist": "3a30e079e8692cc09776186014090835"}) | ||
} |
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,56 @@ | ||
/* | ||
Copyright © 2020 NAME HERE <EMAIL ADDRESS> | ||
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 ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/ttacon/chalk" | ||
) | ||
|
||
// createCmd represents the create command | ||
var linkCmd = &cobra.Command{ | ||
Use: "link <alias> <gist> [file]", | ||
Short: "Link a gist or file alias", | ||
Long: `Link a gist or file alias in your config.`, | ||
Args: cobra.MinimumNArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) == 2 { | ||
viper.Set(args[0], map[string]string{"gist": args[1], "file": ""}) | ||
err := viper.WriteConfig() | ||
if CheckError(err) {return} | ||
fmt.Println(NewMessage(chalk.Green, "Successfully wrote gist alias"). | ||
ThenColor(chalk.Cyan, args[0]). | ||
ThenColor(chalk.Green, "as"). | ||
ThenColor(chalk.Cyan, args[1]).Build()) | ||
} else { | ||
viper.Set(args[0], map[string]string{"gist": args[1], "file": args[2]}) | ||
err := viper.WriteConfig() | ||
if CheckError(err) {return} | ||
fmt.Println(NewMessage(chalk.Green, "Successfully wrote gist alias"). | ||
ThenColor(chalk.Cyan, args[0]). | ||
ThenColor(chalk.Green, "as"). | ||
ThenColor(chalk.Cyan, args[1]). | ||
ThenColor(chalk.Green,"with file"). | ||
ThenColor(chalk.Cyan, args[2]).Build()) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(linkCmd) | ||
} |
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,51 @@ | ||
/* | ||
* Quick Script Runner: A quick and easy way to run gists | ||
* Copyright © 2020 Brett Bender | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package cmd | ||
|
||
import "github.com/ttacon/chalk" | ||
|
||
type Message struct { | ||
message string | ||
} | ||
|
||
func NewMessage(color chalk.Color, message string) *Message { | ||
return &Message{ | ||
message: chalk.Cyan.Color("[QSR] ") + color.Color(message), | ||
} | ||
} | ||
|
||
func (msg *Message) ThenColor(color chalk.Color, message string) *Message { | ||
msg.message = msg.message + " " + color.Color(message) | ||
return msg | ||
} | ||
|
||
func (msg *Message) ThenStyle(style chalk.TextStyle, message string) *Message { | ||
msg.message = msg.message + " " + style.TextStyle(message) | ||
return msg | ||
} | ||
|
||
func (msg *Message) ThenColorStyle(color chalk.Color, style chalk.TextStyle, message string) *Message { | ||
msg.message = msg.message + " " + color.Color(style.TextStyle(message)) | ||
return msg | ||
} | ||
|
||
func (msg *Message) Build() string { | ||
return msg.message | ||
} | ||
|
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
Oops, something went wrong.