-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add description func to scanner interface
- Loading branch information
1 parent
2dd7657
commit 1d0971e
Showing
10 changed files
with
98 additions
and
5 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,49 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"github.com/sundowndev/phoneinfoga/v2/lib/filter" | ||
"github.com/sundowndev/phoneinfoga/v2/lib/remote" | ||
) | ||
|
||
type ScannersCmdOptions struct { | ||
Plugin []string | ||
} | ||
|
||
func init() { | ||
opts := &ScannersCmdOptions{} | ||
scannersCmd := NewScannersCmd(opts) | ||
|
||
fl := scannersCmd.Flags() | ||
fl.StringSliceVar(&opts.Plugin, "plugin", []string{}, "Output file") | ||
|
||
rootCmd.AddCommand(scannersCmd) | ||
} | ||
|
||
func NewScannersCmd(opts *ScannersCmdOptions) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "scanners", | ||
Example: "phoneinfoga scanners", | ||
Short: "Display list of loaded scanners", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, p := range opts.Plugin { | ||
err := remote.OpenPlugin(p) | ||
if err != nil { | ||
exitWithError(err) | ||
} | ||
} | ||
|
||
remoteLibrary := remote.NewLibrary(filter.NewEngine()) | ||
remote.InitScanners(remoteLibrary) | ||
|
||
for i, s := range remoteLibrary.GetAllScanners() { | ||
fmt.Printf("%s\n%s\n", s.Name(), s.Description()) | ||
if i < len(remoteLibrary.GetAllScanners()) { | ||
fmt.Printf("\n") | ||
} | ||
} | ||
}, | ||
} | ||
return cmd | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.