cmd

package
v0.0.0-...-f535d6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "archey-go",
	Short: "Archey-go is a tool to display prettified system info on Arch Linux",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) > 0 {
			cmd.Help()
			os.Exit(0)
		}

		opt := archey.New()

		opt.Show.OS = viper.GetBool("show.no_os")
		opt.Show.Arch = viper.GetBool("show.no_arch")
		opt.Show.Kernel = viper.GetBool("show.no_kernel")
		opt.Show.User = viper.GetBool("show.no_user")
		opt.Show.Hostname = viper.GetBool("show.no_hostname")
		opt.Show.Uptime = viper.GetBool("show.no_uptime")
		opt.Show.UpSince = viper.GetBool("show.no_up_since")
		opt.Show.WM = viper.GetBool("show.no_wm")
		opt.Show.DE = viper.GetBool("show.no_de")
		opt.Show.GTK2Theme = viper.GetBool("show.no_gtk2_theme")
		opt.Show.GTK2IconTheme = viper.GetBool("show.no_gtk2_icon_theme")
		opt.Show.GTK2Font = viper.GetBool("show.no_gtk2_font")
		opt.Show.GTK2CursorTheme = viper.GetBool("show.no_gtk2_cursor_theme")
		opt.Show.GTK3Theme = viper.GetBool("show.no_gtk3_theme")
		opt.Show.GTK3IconTheme = viper.GetBool("show.no_gtk3_icon_theme")
		opt.Show.GTK3Font = viper.GetBool("show.no_gtk3_font")
		opt.Show.GTK3CursorTheme = viper.GetBool("show.no_gtk3_cursor_theme")
		opt.Show.Terminal = viper.GetBool("show.no_terminal")
		opt.Show.Shell = viper.GetBool("show.no_shell")
		opt.Show.Editor = viper.GetBool("show.no_editor")
		opt.Show.Packages = viper.GetBool("show.no_packages")
		opt.Show.Memory = viper.GetBool("show.no_memory")
		opt.Show.Swap = viper.GetBool("show.no_swap")
		opt.Show.CPU = viper.GetBool("show.no_cpu")
		opt.Show.Root = viper.GetBool("show.no_root")
		opt.Show.Home = viper.GetBool("show.no_home")

		if viper.GetString("options.sep") != "" {
			opt.Sep = viper.GetString("options.sep")
		}

		if viper.GetString("options.memory_unit") != "" {
			opt.MemoryUnit = viper.GetString("options.memory_unit")
		}

		if viper.GetString("options.swap_unit") != "" {
			opt.SwapUnit = viper.GetString("options.swap_unit")
		}

		if viper.GetString("options.disk_unit") != "" {
			opt.DiskUnit = viper.GetString("options.disk_unit")
		}

		opt.Paths = viper.GetStringSlice("options.paths")
		opt.PathFull = viper.GetBool("options.path_full")
		opt.ShellFull = viper.GetBool("options.shell_full")

		if viper.GetString("options.up_since_format") != "" {
			opt.UpSinceFormat = viper.GetString("options.up_since_format")
		}

		if viper.GetString("colors.name_color") != "" {
			opt.Colors.Name = viper.GetString("colors.name_color")
		}

		if viper.GetString("colors.text_color") != "" {
			opt.Colors.Text = viper.GetString("colors.text_color")
		}

		if viper.GetString("colors.sep_color") != "" {
			opt.Colors.Sep = viper.GetString("colors.sep_color")
		}

		if len(viper.GetStringSlice("colors.body_color")) != 0 {
			opt.Colors.Body = viper.GetStringSlice("colors.body_color")
		}

		if viper.GetBool("options.no_color") {
			archey.NoColor()
		}

		if cmd.Flag("list-colors").Changed {
			archey.ListColors()
			os.Exit(1)
		}

		if cmd.Flag("version").Changed {
			fmt.Println("Archey-go v" + version)
			os.Exit(0)
		}

		info, err := opt.Render()
		if err != nil {
			return err
		}

		fmt.Println(info)
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL