diff --git a/cmd/clients.go b/cmd/clients.go index a23cc17e4cbd7fff7d035162f9f2a07f68bb90fd..574e031a891ff6a200c83533a80fb53af2a3d124 100644 --- a/cmd/clients.go +++ b/cmd/clients.go @@ -9,6 +9,7 @@ import ( ) var fixedIp bool +var dynamicIp bool var clientsFilename string var clientsCmd = &cobra.Command{ @@ -19,7 +20,20 @@ var clientsCmd = &cobra.Command{ clients := ace.Collection("user") filter := bson.D{} if fixedIp { - filter = bson.D{{"use_fixedip", true}} + filter = bson.D{ + bson.E{"$and", bson.A{ + bson.M{"use_fixedip": bson.M{"$exists": true}}, + bson.M{"use_fixedip": bson.M{"$eq": true}}, + }}, + } + } + if dynamicIp { + filter = bson.D{ + bson.E{"$or", bson.A{ + bson.D{{"use_fixedip", bson.M{"$not": bson.M{"$exists": true}}}}, + bson.M{"use_fixedip": bson.M{"$ne": true}}, + }}, + } } docs, err := utils.FindDocuments(clients, filter) if err != nil { @@ -44,6 +58,7 @@ var clientsCmd = &cobra.Command{ func init() { clientsCmd.Flags().BoolVarP(&fixedIp, "fixed", "f", false, "Only show clients with fixed ip") + clientsCmd.Flags().BoolVarP(&dynamicIp, "dynamic", "d", false, "Only show clients with fixed ip") clientsCmd.Flags().StringVarP(&clientsFilename, "output", "o", "", "Write to file instead of stdout") clientsCmd.Flags().VarP(tableStyleFlag, "style", "s", "Table style") clientsCmd.Flags().VarP(renderModeFlag, "render", "r", "Output rendering mode") diff --git a/cmd/root.go b/cmd/root.go index ff1dfe8c4729d75586dce5fa780290c785218744..788bfb343ded0b886b8def4f2323711e9cf5be9f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -62,7 +62,7 @@ func init() { cobra.OnInitialize(initEnv) RootCmd.PersistentFlags().StringP("address", "a", "192.168.1.1", "Address to the UDM SSH server") RootCmd.PersistentFlags().StringP("password", "p", "", "SSH password") - RootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "Show debug output") + RootCmd.PersistentFlags().BoolVarP(&debug, "debug", "", false, "Show debug output") viper.SetEnvPrefix("SSH") viper.BindPFlag("ADDRESS", RootCmd.PersistentFlags().Lookup("address")) viper.BindPFlag("PASSWORD", RootCmd.PersistentFlags().Lookup("password")) diff --git a/docs/udm-query.md b/docs/udm-query.md index 87bbfd988c0ad82d84fb45323f440f4eaeb710b6..ee790b8e6b5e8387140b5f79a6cf18867ed2b082 100644 --- a/docs/udm-query.md +++ b/docs/udm-query.md @@ -6,7 +6,7 @@ Tool to query Ubiquiti UniFi Dream Machines ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -h, --help help for udm-query -p, --password string SSH password ``` diff --git a/docs/udm-query_clients.md b/docs/udm-query_clients.md index 7a0e87c20d5bc33d19829f9a4ab6607663313415..8b5c347aa882b5a2e3aa6d7dbc48fef0dd0cd35f 100644 --- a/docs/udm-query_clients.md +++ b/docs/udm-query_clients.md @@ -9,6 +9,7 @@ udm-query clients [flags] ### Options ``` + -d, --dynamic Only show clients with fixed ip -f, --fixed Only show clients with fixed ip -h, --help help for clients -o, --output string Write to file instead of stdout @@ -20,7 +21,7 @@ udm-query clients [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_completion.md b/docs/udm-query_completion.md index 9c228d4a7d777b4669ecb664b31d52a885df9603..840e1c3c51c85c90b68238f1ad43da579efaf0e7 100644 --- a/docs/udm-query_completion.md +++ b/docs/udm-query_completion.md @@ -18,7 +18,7 @@ See each sub-command's help for details on how to use the generated script. ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_completion_bash.md b/docs/udm-query_completion_bash.md index 5bb9789411a0e6f060620232b173b641a0bb3e52..40403478621222d8e39aa56972f296f38b0c8d6b 100644 --- a/docs/udm-query_completion_bash.md +++ b/docs/udm-query_completion_bash.md @@ -41,7 +41,7 @@ udm-query completion bash ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_completion_fish.md b/docs/udm-query_completion_fish.md index ea8dc423099c727a369bccb2340743dc717add12..08da55fa793efcaa4c74f15217186cce1cbdb509 100644 --- a/docs/udm-query_completion_fish.md +++ b/docs/udm-query_completion_fish.md @@ -32,7 +32,7 @@ udm-query completion fish [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_completion_powershell.md b/docs/udm-query_completion_powershell.md index a282dbb1cf71662dc8555b2599765349d3afc258..ed6d822b371623314f3ec9d8a8af164e2e1b0f0b 100644 --- a/docs/udm-query_completion_powershell.md +++ b/docs/udm-query_completion_powershell.md @@ -29,7 +29,7 @@ udm-query completion powershell [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_completion_zsh.md b/docs/udm-query_completion_zsh.md index cb826a66e5d53cb4248bbcafc5f31b92b1c862ca..359cd802ccf71382a1fb691986ab4619b94ddd8d 100644 --- a/docs/udm-query_completion_zsh.md +++ b/docs/udm-query_completion_zsh.md @@ -39,7 +39,7 @@ udm-query completion zsh [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_devices.md b/docs/udm-query_devices.md index 31c4473b633ff1a1ab900f831638951a8b4bcd36..765e18906e10c8ec598127e8ec2102084ddae882 100644 --- a/docs/udm-query_devices.md +++ b/docs/udm-query_devices.md @@ -19,7 +19,7 @@ udm-query devices [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_dump.md b/docs/udm-query_dump.md index 2bed4749c860fea7d8ddce5bdc192bcb483efc21..a4b6fdbdae6917e9db790a3b46d4b2b574b794cf 100644 --- a/docs/udm-query_dump.md +++ b/docs/udm-query_dump.md @@ -20,7 +20,7 @@ udm-query dump [flags] <database> <collection> [fields] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_list.md b/docs/udm-query_list.md index eb9c882d8b7e56cf39e45c42cfca54e3369df0bc..f1b1815d4b0d925221ada0fad152763aa7c16ffb 100644 --- a/docs/udm-query_list.md +++ b/docs/udm-query_list.md @@ -17,7 +17,7 @@ udm-query list [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_ping.md b/docs/udm-query_ping.md index dade5532d55117ec52ec581ae393cfb24644b807..aee6602a2089da3bf2294f3ecc8a0243b664d0d9 100644 --- a/docs/udm-query_ping.md +++ b/docs/udm-query_ping.md @@ -16,7 +16,7 @@ udm-query ping [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ``` diff --git a/docs/udm-query_version.md b/docs/udm-query_version.md index eff70084d06afdac82f6e5cc31da1c251af0c9fb..b6408b47638e583d78da97d18ce0cac1d8d7eceb 100644 --- a/docs/udm-query_version.md +++ b/docs/udm-query_version.md @@ -16,7 +16,7 @@ udm-query version [flags] ``` -a, --address string Address to the UDM SSH server (default "192.168.1.1") - -d, --debug Show debug output + --debug Show debug output -p, --password string SSH password ```