-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package info | ||
|
||
import ( | ||
"io/fs" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type sysinfo struct { | ||
OS osinfo `json:"os"` | ||
Workspace workspace `json:"workspace"` | ||
Playwright pwinfo `json:"playwright"` | ||
Rod rodinfo `json:"rod"` | ||
EzLogin EZLogin `json:"ez_login"` | ||
} | ||
|
||
func collect() *sysinfo { | ||
var si = new(sysinfo) | ||
var collectors = []func(){ | ||
si.Workspace.collect, | ||
si.Playwright.collect, | ||
si.Rod.collect, | ||
si.EzLogin.collect, | ||
si.OS.collect, | ||
} | ||
for _, c := range collectors { | ||
c() | ||
} | ||
return si | ||
|
||
} | ||
|
||
const ( | ||
home = "$HOME" | ||
) | ||
|
||
var replaceFn = strings.NewReplacer(should(os.UserHomeDir()), home).Replace | ||
|
||
func should(v string, err error) string { | ||
if err != nil { | ||
return "$$$ERROR$$$" | ||
} | ||
return v | ||
} | ||
|
||
func dirnames(des []fs.DirEntry) []string { | ||
var res []string | ||
for _, de := range des { | ||
if de.IsDir() && !strings.HasPrefix(de.Name(), ".") { | ||
res = append(res, de.Name()) | ||
} | ||
} | ||
return res | ||
} | ||
|
||
func looser(err error) string { | ||
return "*ERROR: " + replaceFn(err.Error()) + "*" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package info | ||
|
||
import ( | ||
"github.com/rusq/slackdump/v2/cmd/slackdump/internal/cfg" | ||
"github.com/rusq/slackdump/v2/internal/cache" | ||
) | ||
|
||
type EZLogin struct { | ||
Flags map[string]bool `json:"flags"` | ||
Browser string `json:"browser"` | ||
} | ||
|
||
func (inf *EZLogin) collect() { | ||
inf.Flags = cache.EzLoginFlags() | ||
inf.Browser = cfg.Browser.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters