@@ -18,30 +18,13 @@ func Info(args []string) error {
1818 path := args [0 ]
1919 pkg , err := findSpec (path )
2020 if err != nil {
21- return err
21+ debug (err .Error ())
22+ log ("package not found" )
23+ return nil
2224 }
2325
24- if pkg .Description != "" {
25- log (pkg .Description )
26- }
27- if pkg .Repository != "" {
28- log (pkg .Repository )
29- }
30- if len (pkg .Authors ) != 0 {
31- authors := strings .Join (pkg .Authors , ", " )
32- log ("by %s" , authors )
33- }
34- if pkg .Version != "" {
35- log ("version: %s" , pkg .Version )
36- }
37- if pkg .License != "" {
38- log ("license: %s" , pkg .License )
39- }
40- if isInstalled (pkg ) {
41- log ("✓ installed" )
42- } else {
43- log ("✘ not installed" )
44- }
26+ lines := prepareInfo (pkg )
27+ log (strings .Join (lines , "\n " ))
4528
4629 return nil
4730}
@@ -73,3 +56,34 @@ func readInstalledSpec(fullName string) *spec.Package {
7356 debug ("found installed package" )
7457 return pkg
7558}
59+
60+ // prepareInfo returns detailed package description.
61+ func prepareInfo (pkg * spec.Package ) []string {
62+ lines := []string {}
63+
64+ header := pkg .FullName ()
65+ if pkg .Version != "" {
66+ header += "@" + pkg .Version
67+ }
68+ if len (pkg .Authors ) != 0 {
69+ authors := strings .Join (pkg .Authors , ", " )
70+ header += " by " + authors
71+ }
72+ lines = append (lines , header )
73+
74+ if pkg .Description != "" {
75+ lines = append (lines , pkg .Description )
76+ }
77+ if pkg .Repository != "" {
78+ lines = append (lines , pkg .Repository )
79+ }
80+ if pkg .License != "" {
81+ lines = append (lines , "license: " + pkg .License )
82+ }
83+ if isInstalled (pkg ) {
84+ lines = append (lines , "✓ installed" )
85+ } else {
86+ lines = append (lines , "✘ not installed" )
87+ }
88+ return lines
89+ }
0 commit comments