mirror of
https://github.com/yarlson/lnk.git
synced 2025-08-29 17:49:47 +02:00
Add new output formatting system with flags for color and emoji control: - Introduce OutputConfig and Writer structs for flexible output handling - Add --colors and --emoji/--no-emoji global flags - Refactor commands to use new Writer for consistent formatting - Separate error content from presentation for better flexibility
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/yarlson/lnk/internal/core"
|
|
)
|
|
|
|
func newPushCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "push [message]",
|
|
Short: "🚀 Push local changes to remote repository",
|
|
Long: "Stages all changes, creates a sync commit with the provided message, and pushes to remote.",
|
|
Args: cobra.MaximumNArgs(1),
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
message := "lnk: sync configuration files"
|
|
if len(args) > 0 {
|
|
message = args[0]
|
|
}
|
|
|
|
lnk := core.NewLnk()
|
|
w := GetWriter(cmd)
|
|
|
|
if err := lnk.Push(message); err != nil {
|
|
return err
|
|
}
|
|
|
|
w.Writeln(Rocket("Successfully pushed changes")).
|
|
WriteString(" ").
|
|
Write(Message{Text: "Commit: ", Emoji: "💾"}).
|
|
Writeln(Colored(message, ColorGray)).
|
|
WriteString(" ").
|
|
Writeln(Message{Text: "Synced to remote", Emoji: "📡"}).
|
|
WriteString(" ").
|
|
Writeln(Sparkles("Your dotfiles are up to date!"))
|
|
|
|
return w.Err()
|
|
},
|
|
}
|
|
}
|