-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Showing
424 changed files
with
79,112 additions
and
39 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
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 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
|
||
gtm "github.com/MichaelMure/go-term-markdown" | ||
"github.com/gabrie30/ghorg/colorlog" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var examplesCmd = &cobra.Command{ | ||
Use: "examples", | ||
Short: "Documentation and examples for each SCM provider", | ||
Long: `Get documentation and examples for each SCM provider in the terminal`, | ||
Run: examplesFunc, | ||
} | ||
|
||
func examplesFunc(cmd *cobra.Command, argz []string) { | ||
filePath := fmt.Sprintf("examples/%s.md", argz[0]) | ||
input := getFileContents(filePath) | ||
result := gtm.Render(string(input), 80, 6) | ||
fmt.Println(string(result)) | ||
} | ||
|
||
func getFileContents(filepath string) []byte { | ||
|
||
contents, err := ioutil.ReadFile(filepath) | ||
if err != nil { | ||
colorlog.PrintErrorAndExit("Only supported SCM providers are available for examples, please use one of the following: github, gitlab, bitbucket, or gitea") | ||
} | ||
|
||
return contents | ||
|
||
} |
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
Oops, something went wrong.