diff --git a/cmd/scan.go b/cmd/scan.go index b2bc32474..f18b8dcfa 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -18,6 +18,7 @@ type ScanCmdOptions struct { DisabledScanners []string PluginPaths []string EnvFiles []string + Formats []string } func init() { @@ -31,6 +32,7 @@ func init() { cmd.PersistentFlags().StringArrayVarP(&opts.DisabledScanners, "disable", "D", []string{}, "Scanner to skip for this scan") cmd.PersistentFlags().StringArrayVar(&opts.PluginPaths, "plugin", []string{}, "Extra scanner plugin to use for the scan") cmd.PersistentFlags().StringSliceVar(&opts.EnvFiles, "env-file", []string{}, "Env files to parse environment variables from (looks for .env by default)") + cmd.PersistentFlags().StringSliceVarP(&opts.Formats, "format", "f", []string{}, "Additional format for the given phone number(s)") // scanCmd.PersistentFlags().StringVarP(&input, "input", "i", "", "Text file containing a list of phone numbers to scan (one per line)") // scanCmd.PersistentFlags().StringVarP(&output, "output", "o", "", "Output to save scan results") } @@ -62,7 +64,7 @@ func runScan(opts *ScanCmdOptions) { exitWithError(errors.New("given phone number is not valid")) } - num, err := number.NewNumber(opts.Number) + num, err := number.NewNumber(opts.Number, opts.Formats...) if err != nil { exitWithError(err) } diff --git a/docs/getting-started/usage.md b/docs/getting-started/usage.md index 0567219c6..fa100179a 100644 --- a/docs/getting-started/usage.md +++ b/docs/getting-started/usage.md @@ -16,6 +16,30 @@ phoneinfoga scan -n "+1 555-444-3333" !!! note "Note that the country code is essential. You don't know which country code to use ? [Find it here](https://www.countrycode.org/)" +## Custom formats + +There's several ways to write down phone numbers and the way they're indexed by search engine makes it difficult to find them without applying custom formatting according to the country they come from. So you can specify a custom template that will be used by scanners and enhance the results. + +The letter `x` will be replaced by each digit of the local phone number (excluding 0). Some variables can be used in the template such as : + +| Variable | Description | Example | +|:------------|:------------------------------------------|:-------------| +| CountryCode | Country code of the phone number | 34 | +| Country | Country of the phone number as letters | US | + +### Examples + +```bash +# Add custom format +1 555.444.3333 +phoneinfoga scan -n "+1 555-444-3333" -f "+{{.CountryCode}} xxx.xxx.xxxx" + +# You can specify multiple formats at once +phoneinfoga scan -n "+1 555-444-3333" -f "xxx.xxx.xxxx" -f "xxx-xxx-xxxx" + +# Add custom format 06.78.23.22.11 +phoneinfoga scan -n "+34678232211" -f "0x.xx.xx.xx.xx" +``` +