MCPcopy Create free account
hub / github.com/archlinux-de/pkgstats-cli / newArchitectureCmd

Function newArchitectureCmd

cmd/architecture.go:11–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9)
10
11func newArchitectureCmd() *cobra.Command {
12 architectureCmd := &cobra.Command{
13 Use: "architecture",
14 Aliases: []string{"arch"},
15 Short: "Shows information about CPU and OS architecture",
16 Hidden: true,
17 Args: cobra.NoArgs,
18 RunE: func(cmd *cobra.Command, args []string) error {
19 s := system.NewSystem()
20
21 osArchitecture, err := s.GetArchitecture()
22 if err != nil {
23 return fmt.Errorf("could not get OS architecture: %w", err)
24 }
25
26 systemArchitecture, err := s.GetCpuArchitecture()
27 if err != nil {
28 return fmt.Errorf("could not get CPU architecture: %w", err)
29 }
30
31 fmt.Fprintf(cmd.OutOrStdout(), "You are using a %s CPU on a %s OS\n", systemArchitecture, osArchitecture)
32
33 return nil
34 },
35 }
36
37 architectureCmd.AddCommand(newOsArchitectureCmd())
38 architectureCmd.AddCommand(newSystemArchitectureCmd())
39
40 return architectureCmd
41}
42
43func newOsArchitectureCmd() *cobra.Command {
44 return &cobra.Command{

Callers 1

NewRootCmdFunction · 0.85

Calls 5

GetArchitectureMethod · 0.95
GetCpuArchitectureMethod · 0.95
NewSystemFunction · 0.92
newOsArchitectureCmdFunction · 0.85
newSystemArchitectureCmdFunction · 0.85

Tested by

no test coverage detected