File: root.go

package info (click to toggle)
debpkg 0.0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80 kB
  • sloc: makefile: 33
file content (69 lines) | stat: -rw-r--r-- 1,525 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package cmd

import (
	"fmt"
	"os"

	"github.com/charmbracelet/lipgloss"
	"github.com/spf13/cobra"
)

const version = "1.0.0"

var (
	// Styles for consistent UI
	titleStyle = lipgloss.NewStyle().
		Bold(true).
		Foreground(lipgloss.Color("#00D7FF")).
		MarginLeft(1)

	errorStyle = lipgloss.NewStyle().
		Bold(true).
		Foreground(lipgloss.Color("#FF0000")).
		MarginLeft(1)

	successStyle = lipgloss.NewStyle().
		Bold(true).
		Foreground(lipgloss.Color("#00FF00")).
		MarginLeft(1)

	infoStyle = lipgloss.NewStyle().
		Foreground(lipgloss.Color("#FFFF00")).
		MarginLeft(1)
)

var rootCmd = &cobra.Command{
	Use:   "debpkg",
	Short: "A simple Debian package installer",
	Long: titleStyle.Render("debpkg") + `

A command-line tool for downloading and installing Debian packages from URLs.
This tool simplifies the process of installing .deb packages by handling
the download and installation in one command.`,
	Example: `  debpkg install https://example.com/package.deb
  debpkg --version
  debpkg --help`,
}

func init() {
	rootCmd.Version = version
	rootCmd.SetVersionTemplate(titleStyle.Render("debpkg") + " version " + version + "\n")
}

// Execute runs the root command
func Execute() error {
	return rootCmd.Execute()
}

// Helper functions for consistent output formatting
func PrintError(msg string) {
	fmt.Fprintln(os.Stderr, errorStyle.Render("✗ "+msg))
}

func PrintSuccess(msg string) {
	fmt.Println(successStyle.Render("✓ "+msg))
}

func PrintInfo(msg string) {
	fmt.Println(infoStyle.Render("ℹ "+msg))
}