mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
119 lines
3.9 KiB
Go
119 lines
3.9 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var languagesCmd = &cobra.Command{
|
|
Use: "languages",
|
|
Short: "Show supported languages and their mappings",
|
|
Long: `Display all supported languages for the 'devour get' command
|
|
along with their base URLs and examples.
|
|
|
|
This helps you discover what documentation sources are available
|
|
and how to reference them quickly.`,
|
|
RunE: runLanguages,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(languagesCmd)
|
|
}
|
|
|
|
func runLanguages(cmd *cobra.Command, args []string) error {
|
|
fmt.Println("🌐 Devour Supported Languages")
|
|
fmt.Println("═══════════════════════════════════════════════════════════════")
|
|
fmt.Println()
|
|
|
|
languages := []struct {
|
|
langs []string
|
|
url string
|
|
examples []string
|
|
}{
|
|
{
|
|
langs: []string{"go", "golang"},
|
|
url: "https://pkg.go.dev/{package}",
|
|
examples: []string{"devour get go http", "devour get go fmt", "devour get golang json"},
|
|
},
|
|
{
|
|
langs: []string{"rust"},
|
|
url: "https://docs.rs/{crate}/latest/{crate}/",
|
|
examples: []string{"devour get rust tokio", "devour get rust serde", "devour get rust clap"},
|
|
},
|
|
{
|
|
langs: []string{"python", "py"},
|
|
url: "https://docs.python.org/3/library/{module}.html",
|
|
examples: []string{"devour get python asyncio", "devour get py requests", "devour get python stdlib"},
|
|
},
|
|
{
|
|
langs: []string{"java"},
|
|
url: "https://docs.oracle.com/javase/8/docs/api/{package}.html",
|
|
examples: []string{"devour get java string", "devour get java arraylist"},
|
|
},
|
|
{
|
|
langs: []string{"spring"},
|
|
url: "https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#{section}",
|
|
examples: []string{"devour get spring boot", "devour get spring testing"},
|
|
},
|
|
{
|
|
langs: []string{"typescript", "ts"},
|
|
url: "https://www.typescriptlang.org/docs/handbook/{topic}.html",
|
|
examples: []string{"devour get typescript interfaces", "devour get ts decorators"},
|
|
},
|
|
{
|
|
langs: []string{"react"},
|
|
url: "https://react.dev/reference/react/{feature}",
|
|
examples: []string{"devour get react hooks", "devour get react components", "devour get react state"},
|
|
},
|
|
{
|
|
langs: []string{"vue"},
|
|
url: "https://vuejs.org/guide/{topic}.html",
|
|
examples: []string{"devour get vue components", "devour get vue reactivity"},
|
|
},
|
|
{
|
|
langs: []string{"nuxt"},
|
|
url: "https://nuxt.com/docs/guide/{topic}",
|
|
examples: []string{"devour get nuxt routing", "devour get nuxt middleware"},
|
|
},
|
|
{
|
|
langs: []string{"docker"},
|
|
url: "https://docs.docker.com/{topic}",
|
|
examples: []string{"devour get docker compose", "devour get docker build", "devour get docker networking"},
|
|
},
|
|
{
|
|
langs: []string{"cloudflare", "cf"},
|
|
url: "https://developers.cloudflare.com/{topic}",
|
|
examples: []string{"devour get cloudflare workers", "devour get cf pages", "devour get cloudflare dns"},
|
|
},
|
|
{
|
|
langs: []string{"astro"},
|
|
url: "https://docs.astro.build/en/guides/{topic}",
|
|
examples: []string{"devour get astro routing", "devour get astro components"},
|
|
},
|
|
}
|
|
|
|
for _, lang := range languages {
|
|
fmt.Printf("🔷 %s\n", strings.Join(lang.langs, ", "))
|
|
fmt.Printf(" URL: %s\n", lang.url)
|
|
fmt.Printf(" Examples:\n")
|
|
for _, example := range lang.examples {
|
|
fmt.Printf(" • %s\n", example)
|
|
}
|
|
fmt.Println()
|
|
}
|
|
|
|
fmt.Println("💡 Pro Tips:")
|
|
fmt.Println(" • Use 'devour get <language> help' for language-specific help")
|
|
fmt.Println(" • Add --format markdown for enhanced documentation")
|
|
fmt.Println(" • Most languages support common aliases (e.g., py → python)")
|
|
fmt.Println()
|
|
fmt.Println("🚀 Quick Start:")
|
|
fmt.Println(" devour get go http --format markdown")
|
|
fmt.Println(" devour get python asyncio")
|
|
fmt.Println(" devour get react hooks")
|
|
|
|
return nil
|
|
}
|