66 outputResponse ,
77} from "../helpers.js" ;
88import { parseJsonInput } from "../input.js" ;
9- import { printSuccess } from "../output.js" ;
9+ import { printCount , printSuccess } from "../output.js" ;
1010import { registerAttrsSubcommand } from "./attrs.js" ;
1111import { addExamples } from "./help.js" ;
1212
@@ -31,6 +31,7 @@ export function registerEntitiesCommand(program: Command): void {
3131 . option ( "--offset <n>" , "Skip first N entities" , parseInt )
3232 . option ( "--order-by <field>" , "Order results by field" )
3333 . option ( "--count" , "Include total count in response" )
34+ . option ( "--count-only" , "Only show the total count without listing entities" )
3435 . option ( "--key-values" , "Request simplified key-value format" )
3536 . action (
3637 withErrorHandler ( async ( opts : Record < string , unknown > , cmd : Command ) => {
@@ -50,11 +51,16 @@ export function registerEntitiesCommand(program: Command): void {
5051 if ( opts . limit !== undefined ) params . limit = String ( opts . limit ) ;
5152 if ( opts . offset !== undefined ) params . offset = String ( opts . offset ) ;
5253 if ( opts . orderBy ) params . orderBy = String ( opts . orderBy ) ;
53- if ( opts . count ) params . count = "true" ;
54+ if ( opts . count || opts . countOnly ) params . count = "true" ;
55+ if ( opts . countOnly ) params . limit = "0" ;
5456 if ( opts . keyValues ) params . options = "keyValues" ;
5557
5658 const response = await client . get ( "/entities" , params ) ;
57- outputResponse ( response , format , ! ! opts . count ) ;
59+ if ( opts . countOnly ) {
60+ printCount ( response . count ?? 0 ) ;
61+ } else {
62+ outputResponse ( response , format , ! ! opts . count ) ;
63+ }
5864 } ) ,
5965 ) ;
6066
@@ -117,6 +123,10 @@ export function registerEntitiesCommand(program: Command): void {
117123 description : "Get total count with results" ,
118124 command : "geonic entities list --type Sensor --count" ,
119125 } ,
126+ {
127+ description : "Get only the total count (no entity data)" ,
128+ command : "geonic entities list --type Sensor --count-only" ,
129+ } ,
120130 ] ) ;
121131
122132 // entities get
0 commit comments