@geolonia/geonicdb-cli 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1969,7 +1969,9 @@ function addAttrsSubcommands(attrs) {
1969
1969
  command: "geonic entities attrs get urn:ngsi-ld:Sensor:001 temperature"
1970
1970
  }
1971
1971
  ]);
1972
- const add = attrs.command("add").description("Add attributes to an entity").argument("<entityId>", "Entity ID").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
1972
+ const add = attrs.command("add").description(
1973
+ 'Add attributes to an entity\n\nJSON payload example:\n {"humidity": {"type": "Property", "value": 60}}'
1974
+ ).argument("<entityId>", "Entity ID").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
1973
1975
  withErrorHandler(
1974
1976
  async (entityId, json, _opts, cmd) => {
1975
1977
  const client = createClient(cmd);
@@ -1983,12 +1985,22 @@ function addAttrsSubcommands(attrs) {
1983
1985
  )
1984
1986
  );
1985
1987
  addExamples(add, [
1988
+ {
1989
+ description: "Add an attribute with inline JSON",
1990
+ command: `geonic entities attrs add urn:ngsi-ld:Sensor:001 '{"humidity":{"type":"Property","value":60}}'`
1991
+ },
1986
1992
  {
1987
1993
  description: "Add attributes from a file",
1988
1994
  command: "geonic entities attrs add urn:ngsi-ld:Sensor:001 @attrs.json"
1995
+ },
1996
+ {
1997
+ description: "Add from stdin pipe",
1998
+ command: "cat attrs.json | geonic entities attrs add urn:ngsi-ld:Sensor:001"
1989
1999
  }
1990
2000
  ]);
1991
- const attrUpdate = attrs.command("update").description("Update a specific attribute of an entity").argument("<entityId>", "Entity ID").argument("<attrName>", "Attribute name").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
2001
+ const attrUpdate = attrs.command("update").description(
2002
+ 'Update a specific attribute of an entity\n\nJSON payload example:\n {"type": "Property", "value": 25}'
2003
+ ).argument("<entityId>", "Entity ID").argument("<attrName>", "Attribute name").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
1992
2004
  withErrorHandler(
1993
2005
  async (entityId, attrName, json, _opts, cmd) => {
1994
2006
  const client = createClient(cmd);
@@ -2003,8 +2015,12 @@ function addAttrsSubcommands(attrs) {
2003
2015
  );
2004
2016
  addExamples(attrUpdate, [
2005
2017
  {
2006
- description: "Update a specific attribute",
2007
- command: `geonic entities attrs update urn:ngsi-ld:Sensor:001 temperature '{"value":25}'`
2018
+ description: "Update a Property value",
2019
+ command: `geonic entities attrs update urn:ngsi-ld:Sensor:001 temperature '{"type":"Property","value":25}'`
2020
+ },
2021
+ {
2022
+ description: "Update from a file",
2023
+ command: "geonic entities attrs update urn:ngsi-ld:Sensor:001 temperature @attr.json"
2008
2024
  }
2009
2025
  ]);
2010
2026
  const del = attrs.command("delete").description("Delete a specific attribute from an entity").argument("<entityId>", "Entity ID").argument("<attrName>", "Attribute name").action(
@@ -2147,7 +2163,9 @@ function registerEntitiesCommand(program2) {
2147
2163
  command: "geonic entities get urn:ngsi-ld:Sensor:001 --key-values"
2148
2164
  }
2149
2165
  ]);
2150
- const create = entities.command("create").description("Create a new entity").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
2166
+ const create = entities.command("create").description(
2167
+ 'Create a new entity\n\nJSON payload example:\n {\n "id": "urn:ngsi-ld:Sensor:001",\n "type": "Sensor",\n "temperature": {"type": "Property", "value": 25}\n }'
2168
+ ).argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
2151
2169
  withErrorHandler(async (json, _opts, cmd) => {
2152
2170
  const client = createClient(cmd);
2153
2171
  const data = await parseJsonInput(json);
@@ -2157,9 +2175,13 @@ function registerEntitiesCommand(program2) {
2157
2175
  );
2158
2176
  addExamples(create, [
2159
2177
  {
2160
- description: "Create from inline JSON",
2178
+ description: "Create from inline JSON (minimal)",
2161
2179
  command: `geonic entities create '{"id":"urn:ngsi-ld:Sensor:001","type":"Sensor"}'`
2162
2180
  },
2181
+ {
2182
+ description: "Create with attributes",
2183
+ command: `geonic entities create '{"id":"urn:ngsi-ld:Sensor:001","type":"Sensor","temperature":{"type":"Property","value":25},"location":{"type":"GeoProperty","value":{"type":"Point","coordinates":[139.77,35.68]}}}'`
2184
+ },
2163
2185
  {
2164
2186
  description: "Create from a file",
2165
2187
  command: "geonic entities create @entity.json"
@@ -2167,9 +2189,15 @@ function registerEntitiesCommand(program2) {
2167
2189
  {
2168
2190
  description: "Create from stdin pipe",
2169
2191
  command: "cat entity.json | geonic entities create"
2192
+ },
2193
+ {
2194
+ description: "Interactive mode (omit JSON argument)",
2195
+ command: "geonic entities create"
2170
2196
  }
2171
2197
  ]);
2172
- const update = entities.command("update").description("Update attributes of an entity (PATCH)").argument("<id>", "Entity ID").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
2198
+ const update = entities.command("update").description(
2199
+ 'Update attributes of an entity (PATCH)\n\nJSON payload: only specified attributes are modified.\n e.g. {"temperature": {"type": "Property", "value": 30}}'
2200
+ ).argument("<id>", "Entity ID").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
2173
2201
  withErrorHandler(
2174
2202
  async (id, json, _opts, cmd) => {
2175
2203
  const client = createClient(cmd);
@@ -2184,15 +2212,21 @@ function registerEntitiesCommand(program2) {
2184
2212
  );
2185
2213
  addExamples(update, [
2186
2214
  {
2187
- description: "Update entity attributes from inline JSON",
2188
- command: `geonic entities update urn:ngsi-ld:Sensor:001 '{"temperature":{"value":25}}'`
2215
+ description: "Update a Property attribute",
2216
+ command: `geonic entities update urn:ngsi-ld:Sensor:001 '{"temperature":{"type":"Property","value":30}}'`
2189
2217
  },
2190
2218
  {
2191
- description: "Update entity attributes from a file",
2219
+ description: "Update from a file",
2192
2220
  command: "geonic entities update urn:ngsi-ld:Sensor:001 @attrs.json"
2221
+ },
2222
+ {
2223
+ description: "Update from stdin pipe",
2224
+ command: "cat attrs.json | geonic entities update urn:ngsi-ld:Sensor:001"
2193
2225
  }
2194
2226
  ]);
2195
- const replace = entities.command("replace").description("Replace all attributes of an entity (PUT)").argument("<id>", "Entity ID").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
2227
+ const replace = entities.command("replace").description(
2228
+ 'Replace all attributes of an entity (PUT)\n\nJSON payload: all existing attributes are replaced.\n e.g. {"temperature": {"type": "Property", "value": 20}}'
2229
+ ).argument("<id>", "Entity ID").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
2196
2230
  withErrorHandler(
2197
2231
  async (id, json, _opts, cmd) => {
2198
2232
  const client = createClient(cmd);
@@ -2207,8 +2241,16 @@ function registerEntitiesCommand(program2) {
2207
2241
  );
2208
2242
  addExamples(replace, [
2209
2243
  {
2210
- description: "Replace all attributes from a file",
2244
+ description: "Replace all attributes with inline JSON",
2245
+ command: `geonic entities replace urn:ngsi-ld:Sensor:001 '{"temperature":{"type":"Property","value":20}}'`
2246
+ },
2247
+ {
2248
+ description: "Replace from a file",
2211
2249
  command: "geonic entities replace urn:ngsi-ld:Sensor:001 @attrs.json"
2250
+ },
2251
+ {
2252
+ description: "Replace from stdin pipe",
2253
+ command: "cat attrs.json | geonic entities replace urn:ngsi-ld:Sensor:001"
2212
2254
  }
2213
2255
  ]);
2214
2256
  const upsert = entities.command("upsert").description("Create or update entities").argument("[json]", "JSON payload (inline, @file, - for stdin, or omit for interactive/pipe)").action(
@@ -2248,7 +2290,9 @@ function registerEntitiesCommand(program2) {
2248
2290
  // src/commands/batch.ts
2249
2291
  function registerBatchCommand(program2) {
2250
2292
  const batch = program2.command("entityOperations").alias("batch").description("Perform batch operations on entities");
2251
- const create = batch.command("create [json]").description("Batch create entities").action(
2293
+ const create = batch.command("create [json]").description(
2294
+ 'Batch create entities\n\nJSON payload: an array of NGSI-LD entities.\n e.g. [{"id": "urn:ngsi-ld:Sensor:001", "type": "Sensor"}, ...]'
2295
+ ).action(
2252
2296
  withErrorHandler(async (json, _opts, cmd) => {
2253
2297
  const client = createClient(cmd);
2254
2298
  const format = getFormat(cmd);
@@ -2258,16 +2302,22 @@ function registerBatchCommand(program2) {
2258
2302
  })
2259
2303
  );
2260
2304
  addExamples(create, [
2305
+ {
2306
+ description: "Batch create with inline JSON",
2307
+ command: `geonic batch create '[{"id":"urn:ngsi-ld:Sensor:001","type":"Sensor"},{"id":"urn:ngsi-ld:Sensor:002","type":"Sensor"}]'`
2308
+ },
2261
2309
  {
2262
2310
  description: "Batch create from a file",
2263
2311
  command: "geonic batch create @entities.json"
2264
2312
  },
2265
2313
  {
2266
- description: "Batch create from stdin",
2314
+ description: "Batch create from stdin pipe",
2267
2315
  command: "cat entities.json | geonic batch create"
2268
2316
  }
2269
2317
  ]);
2270
- const upsert = batch.command("upsert [json]").description("Batch upsert entities").action(
2318
+ const upsert = batch.command("upsert [json]").description(
2319
+ "Batch upsert entities\n\nJSON payload: an array of NGSI-LD entities.\nCreates entities that don't exist, updates those that do."
2320
+ ).action(
2271
2321
  withErrorHandler(async (json, _opts, cmd) => {
2272
2322
  const client = createClient(cmd);
2273
2323
  const format = getFormat(cmd);
@@ -2277,16 +2327,22 @@ function registerBatchCommand(program2) {
2277
2327
  })
2278
2328
  );
2279
2329
  addExamples(upsert, [
2330
+ {
2331
+ description: "Batch upsert with inline JSON",
2332
+ command: `geonic batch upsert '[{"id":"urn:ngsi-ld:Sensor:001","type":"Sensor","temperature":{"type":"Property","value":25}}]'`
2333
+ },
2280
2334
  {
2281
2335
  description: "Batch upsert from a file",
2282
2336
  command: "geonic batch upsert @entities.json"
2283
2337
  },
2284
2338
  {
2285
- description: "Batch upsert from stdin",
2339
+ description: "Batch upsert from stdin pipe",
2286
2340
  command: "cat entities.json | geonic batch upsert"
2287
2341
  }
2288
2342
  ]);
2289
- const update = batch.command("update [json]").description("Batch update entity attributes").action(
2343
+ const update = batch.command("update [json]").description(
2344
+ "Batch update entity attributes\n\nJSON payload: an array of NGSI-LD entities with attributes to update.\nEach entity must include id and type; only specified attributes are modified."
2345
+ ).action(
2290
2346
  withErrorHandler(async (json, _opts, cmd) => {
2291
2347
  const client = createClient(cmd);
2292
2348
  const format = getFormat(cmd);
@@ -2305,7 +2361,9 @@ function registerBatchCommand(program2) {
2305
2361
  command: "cat updates.json | geonic batch update"
2306
2362
  }
2307
2363
  ]);
2308
- const del = batch.command("delete [json]").description("Batch delete entities by ID").action(
2364
+ const del = batch.command("delete [json]").description(
2365
+ 'Batch delete entities by ID\n\nJSON payload: an array of entity ID strings.\n e.g. ["urn:ngsi-ld:Sensor:001","urn:ngsi-ld:Sensor:002"]'
2366
+ ).action(
2309
2367
  withErrorHandler(async (json, _opts, cmd) => {
2310
2368
  const client = createClient(cmd);
2311
2369
  const format = getFormat(cmd);
@@ -2315,16 +2373,22 @@ function registerBatchCommand(program2) {
2315
2373
  })
2316
2374
  );
2317
2375
  addExamples(del, [
2376
+ {
2377
+ description: "Batch delete with inline JSON",
2378
+ command: `geonic batch delete '["urn:ngsi-ld:Sensor:001","urn:ngsi-ld:Sensor:002"]'`
2379
+ },
2318
2380
  {
2319
2381
  description: "Batch delete from a file",
2320
2382
  command: "geonic batch delete @entity-ids.json"
2321
2383
  },
2322
2384
  {
2323
- description: "Batch delete from stdin",
2385
+ description: "Batch delete from stdin pipe",
2324
2386
  command: "cat entity-ids.json | geonic batch delete"
2325
2387
  }
2326
2388
  ]);
2327
- const query = batch.command("query [json]").description("Query entities by posting a query payload").action(
2389
+ const query = batch.command("query [json]").description(
2390
+ 'Query entities by posting a query payload\n\nJSON payload example:\n {\n "entities": [{"type": "Sensor"}],\n "attrs": ["temperature"],\n "q": "temperature>30"\n }'
2391
+ ).action(
2328
2392
  withErrorHandler(async (json, _opts, cmd) => {
2329
2393
  const client = createClient(cmd);
2330
2394
  const format = getFormat(cmd);
@@ -2335,15 +2399,21 @@ function registerBatchCommand(program2) {
2335
2399
  );
2336
2400
  addExamples(query, [
2337
2401
  {
2338
- description: "Query entities from a file",
2402
+ description: "Query with inline JSON",
2403
+ command: `geonic batch query '{"entities":[{"type":"Sensor"}],"attrs":["temperature"]}'`
2404
+ },
2405
+ {
2406
+ description: "Query from a file",
2339
2407
  command: "geonic batch query @query.json"
2340
2408
  },
2341
2409
  {
2342
- description: "Query entities from stdin",
2410
+ description: "Query from stdin pipe",
2343
2411
  command: "cat query.json | geonic batch query"
2344
2412
  }
2345
2413
  ]);
2346
- const merge = batch.command("merge [json]").description("Batch merge-patch entities").action(
2414
+ const merge = batch.command("merge [json]").description(
2415
+ "Batch merge-patch entities\n\nJSON payload: an array of NGSI-LD entities.\nEach entity must include id and type; attributes are merge-patched."
2416
+ ).action(
2347
2417
  withErrorHandler(async (json, _opts, cmd) => {
2348
2418
  const client = createClient(cmd);
2349
2419
  const format = getFormat(cmd);
@@ -2410,7 +2480,9 @@ function registerSubscriptionsCommand(program2) {
2410
2480
  command: "geonic subscriptions get urn:ngsi-ld:Subscription:001"
2411
2481
  }
2412
2482
  ]);
2413
- const create = subscriptions.command("create [json]").description("Create a subscription").action(
2483
+ const create = subscriptions.command("create [json]").description(
2484
+ 'Create a subscription\n\nJSON payload example:\n {\n "type": "Subscription",\n "entities": [{"type": "Sensor"}],\n "watchedAttributes": ["temperature"],\n "notification": {"endpoint": {"uri": "http://localhost:3000/notify"}}\n }'
2485
+ ).action(
2414
2486
  withErrorHandler(async (json, _opts, cmd) => {
2415
2487
  const client = createClient(cmd);
2416
2488
  const format = getFormat(cmd);
@@ -2421,16 +2493,26 @@ function registerSubscriptionsCommand(program2) {
2421
2493
  })
2422
2494
  );
2423
2495
  addExamples(create, [
2496
+ {
2497
+ description: "Create with inline JSON",
2498
+ command: `geonic subscriptions create '{"type":"Subscription","entities":[{"type":"Sensor"}],"watchedAttributes":["temperature"],"notification":{"endpoint":{"uri":"http://localhost:3000/notify"}}}'`
2499
+ },
2424
2500
  {
2425
2501
  description: "Create from a JSON file",
2426
2502
  command: "geonic subscriptions create @subscription.json"
2427
2503
  },
2428
2504
  {
2429
- description: "Create from stdin",
2505
+ description: "Create from stdin pipe",
2430
2506
  command: "cat subscription.json | geonic subscriptions create"
2507
+ },
2508
+ {
2509
+ description: "Interactive mode",
2510
+ command: "geonic subscriptions create"
2431
2511
  }
2432
2512
  ]);
2433
- const update = subscriptions.command("update <id> [json]").description("Update a subscription").action(
2513
+ const update = subscriptions.command("update <id> [json]").description(
2514
+ 'Update a subscription\n\nJSON payload: only specified fields are updated.\n e.g. {"description": "Updated subscription"}'
2515
+ ).action(
2434
2516
  withErrorHandler(
2435
2517
  async (id, json, _opts, cmd) => {
2436
2518
  const client = createClient(cmd);
@@ -2447,8 +2529,16 @@ function registerSubscriptionsCommand(program2) {
2447
2529
  );
2448
2530
  addExamples(update, [
2449
2531
  {
2450
- description: "Update a subscription from a file",
2532
+ description: "Update description",
2533
+ command: `geonic subscriptions update urn:ngsi-ld:Subscription:001 '{"description":"Updated subscription"}'`
2534
+ },
2535
+ {
2536
+ description: "Update from a file",
2451
2537
  command: "geonic subscriptions update urn:ngsi-ld:Subscription:001 @sub.json"
2538
+ },
2539
+ {
2540
+ description: "Update from stdin pipe",
2541
+ command: "cat sub.json | geonic subscriptions update urn:ngsi-ld:Subscription:001"
2452
2542
  }
2453
2543
  ]);
2454
2544
  const del = subscriptions.command("delete <id>").description("Delete a subscription").action(
@@ -2510,7 +2600,9 @@ function registerRegistrationsCommand(program2) {
2510
2600
  command: "geonic registrations get urn:ngsi-ld:ContextSourceRegistration:001"
2511
2601
  }
2512
2602
  ]);
2513
- const create = registrations.command("create [json]").description("Create a registration").action(
2603
+ const create = registrations.command("create [json]").description(
2604
+ 'Create a registration\n\nJSON payload example:\n {\n "type": "ContextSourceRegistration",\n "information": [{"entities": [{"type": "Room"}]}],\n "endpoint": "http://localhost:4000/source"\n }'
2605
+ ).action(
2514
2606
  withErrorHandler(async (json, _opts, cmd) => {
2515
2607
  const client = createClient(cmd);
2516
2608
  const format = getFormat(cmd);
@@ -2522,8 +2614,16 @@ function registerRegistrationsCommand(program2) {
2522
2614
  );
2523
2615
  addExamples(create, [
2524
2616
  {
2525
- description: "Create a registration from a file",
2617
+ description: "Create with inline JSON",
2618
+ command: `geonic registrations create '{"type":"ContextSourceRegistration","information":[{"entities":[{"type":"Room"}]}],"endpoint":"http://localhost:4000/source"}'`
2619
+ },
2620
+ {
2621
+ description: "Create from a file",
2526
2622
  command: "geonic registrations create @registration.json"
2623
+ },
2624
+ {
2625
+ description: "Create from stdin pipe",
2626
+ command: "cat registration.json | geonic registrations create"
2527
2627
  }
2528
2628
  ]);
2529
2629
  const regUpdate = registrations.command("update <id> [json]").description("Update a registration").action(
@@ -2543,8 +2643,16 @@ function registerRegistrationsCommand(program2) {
2543
2643
  );
2544
2644
  addExamples(regUpdate, [
2545
2645
  {
2546
- description: "Update a registration from a file",
2646
+ description: "Update endpoint",
2647
+ command: `geonic registrations update urn:ngsi-ld:ContextSourceRegistration:001 '{"endpoint":"http://localhost:5000/source"}'`
2648
+ },
2649
+ {
2650
+ description: "Update from a file",
2547
2651
  command: "geonic registrations update urn:ngsi-ld:ContextSourceRegistration:001 @registration.json"
2652
+ },
2653
+ {
2654
+ description: "Update from stdin pipe",
2655
+ command: "cat registration.json | geonic registrations update urn:ngsi-ld:ContextSourceRegistration:001"
2548
2656
  }
2549
2657
  ]);
2550
2658
  const del = registrations.command("delete <id>").description("Delete a registration").action(
@@ -2722,11 +2830,21 @@ function registerTemporalCommand(program2) {
2722
2830
  command: "geonic temporal entities get urn:ngsi-ld:Sensor:001 --last-n 10"
2723
2831
  }
2724
2832
  ]);
2725
- const create = entities.command("create [json]").description("Create a temporal entity").action(createCreateAction());
2833
+ const create = entities.command("create [json]").description(
2834
+ "Create a temporal entity\n\nJSON payload: an NGSI-LD entity with temporal attribute instances.\nEach attribute value is an array of {value, observedAt} objects."
2835
+ ).action(createCreateAction());
2726
2836
  addExamples(create, [
2727
2837
  {
2728
- description: "Create temporal entity from a file",
2838
+ description: "Create from a file",
2729
2839
  command: "geonic temporal entities create @temporal-entity.json"
2840
+ },
2841
+ {
2842
+ description: "Create from stdin pipe",
2843
+ command: "cat temporal-entity.json | geonic temporal entities create"
2844
+ },
2845
+ {
2846
+ description: "Interactive mode",
2847
+ command: "geonic temporal entities create"
2730
2848
  }
2731
2849
  ]);
2732
2850
  const del = entities.command("delete <id>").description("Delete a temporal entity by ID").action(createDeleteAction());
@@ -2741,6 +2859,10 @@ function registerTemporalCommand(program2) {
2741
2859
  );
2742
2860
  opsQuery.action(createQueryAction());
2743
2861
  addExamples(opsQuery, [
2862
+ {
2863
+ description: "Query with inline JSON",
2864
+ command: `geonic temporal entityOperations query '{"entities":[{"type":"Sensor"}],"attrs":["temperature"]}'`
2865
+ },
2744
2866
  {
2745
2867
  description: "Query with aggregation (hourly count)",
2746
2868
  command: "geonic temporal entityOperations query @query.json --aggr-methods totalCount --aggr-period PT1H"
@@ -2888,7 +3010,9 @@ function registerTenantsCommand(parent) {
2888
3010
  command: "geonic admin tenants get <tenant-id>"
2889
3011
  }
2890
3012
  ]);
2891
- const create = tenants.command("create [json]").description("Create a new tenant").action(
3013
+ const create = tenants.command("create [json]").description(
3014
+ 'Create a new tenant\n\nJSON payload example:\n {\n "name": "production",\n "description": "Production environment tenant"\n }'
3015
+ ).action(
2892
3016
  withErrorHandler(async (json, _opts, cmd) => {
2893
3017
  const body = await parseJsonInput(json);
2894
3018
  const client = createClient(cmd);
@@ -2902,11 +3026,29 @@ function registerTenantsCommand(parent) {
2902
3026
  );
2903
3027
  addExamples(create, [
2904
3028
  {
2905
- description: "Create a tenant from a JSON file",
3029
+ description: "Create with inline JSON",
3030
+ command: `geonic admin tenants create '{"name":"my-tenant","description":"My first tenant"}'`
3031
+ },
3032
+ {
3033
+ description: "Minimal (name only)",
3034
+ command: `geonic admin tenants create '{"name":"production"}'`
3035
+ },
3036
+ {
3037
+ description: "Create from a JSON file",
2906
3038
  command: "geonic admin tenants create @tenant.json"
3039
+ },
3040
+ {
3041
+ description: "Create from stdin pipe",
3042
+ command: "cat tenant.json | geonic admin tenants create"
3043
+ },
3044
+ {
3045
+ description: "Interactive mode (omit JSON argument)",
3046
+ command: "geonic admin tenants create"
2907
3047
  }
2908
3048
  ]);
2909
- const update = tenants.command("update <id> [json]").description("Update a tenant").action(
3049
+ const update = tenants.command("update <id> [json]").description(
3050
+ 'Update a tenant\n\nJSON payload: only specified fields are updated.\n e.g. {"name": "new-name", "description": "Updated description"}'
3051
+ ).action(
2910
3052
  withErrorHandler(
2911
3053
  async (id, json, _opts, cmd) => {
2912
3054
  const body = await parseJsonInput(json);
@@ -2924,8 +3066,24 @@ function registerTenantsCommand(parent) {
2924
3066
  );
2925
3067
  addExamples(update, [
2926
3068
  {
2927
- description: "Update a tenant from a JSON file",
2928
- command: "geonic admin tenants update <tenant-id> @tenant.json"
3069
+ description: "Update description with inline JSON",
3070
+ command: `geonic admin tenants update <tenant-id> '{"description":"Updated description"}'`
3071
+ },
3072
+ {
3073
+ description: "Rename a tenant",
3074
+ command: `geonic admin tenants update <tenant-id> '{"name":"new-name"}'`
3075
+ },
3076
+ {
3077
+ description: "Update from a JSON file",
3078
+ command: "geonic admin tenants update <tenant-id> @patch.json"
3079
+ },
3080
+ {
3081
+ description: "Update from stdin pipe",
3082
+ command: "cat patch.json | geonic admin tenants update <tenant-id>"
3083
+ },
3084
+ {
3085
+ description: "Interactive mode",
3086
+ command: "geonic admin tenants update <tenant-id>"
2929
3087
  }
2930
3088
  ]);
2931
3089
  const del = tenants.command("delete <id>").description("Delete a tenant").action(
@@ -3012,7 +3170,9 @@ function registerUsersCommand(parent) {
3012
3170
  command: "geonic admin users get <user-id>"
3013
3171
  }
3014
3172
  ]);
3015
- const create = users.command("create [json]").description("Create a new user").action(
3173
+ const create = users.command("create [json]").description(
3174
+ 'Create a new user\n\nJSON payload example:\n {\n "email": "user@example.com",\n "password": "SecurePassword123!",\n "role": "super_admin"\n }'
3175
+ ).action(
3016
3176
  withErrorHandler(async (json, _opts, cmd) => {
3017
3177
  const body = await parseJsonInput(json);
3018
3178
  const client = createClient(cmd);
@@ -3026,11 +3186,21 @@ function registerUsersCommand(parent) {
3026
3186
  );
3027
3187
  addExamples(create, [
3028
3188
  {
3029
- description: "Create a user from a JSON file",
3189
+ description: "Create with inline JSON",
3190
+ command: `geonic admin users create '{"email":"user@example.com","password":"SecurePassword123!","role":"super_admin"}'`
3191
+ },
3192
+ {
3193
+ description: "Create from a JSON file",
3030
3194
  command: "geonic admin users create @user.json"
3195
+ },
3196
+ {
3197
+ description: "Create from stdin pipe",
3198
+ command: "cat user.json | geonic admin users create"
3031
3199
  }
3032
3200
  ]);
3033
- const update = users.command("update <id> [json]").description("Update a user").action(
3201
+ const update = users.command("update <id> [json]").description(
3202
+ 'Update a user\n\nJSON payload: only specified fields are updated.\n e.g. {"role": "admin"}'
3203
+ ).action(
3034
3204
  withErrorHandler(
3035
3205
  async (id, json, _opts, cmd) => {
3036
3206
  const body = await parseJsonInput(json);
@@ -3048,8 +3218,16 @@ function registerUsersCommand(parent) {
3048
3218
  );
3049
3219
  addExamples(update, [
3050
3220
  {
3051
- description: "Update a user from a JSON file",
3221
+ description: "Update role with inline JSON",
3222
+ command: `geonic admin users update <user-id> '{"role":"admin"}'`
3223
+ },
3224
+ {
3225
+ description: "Update from a JSON file",
3052
3226
  command: "geonic admin users update <user-id> @user.json"
3227
+ },
3228
+ {
3229
+ description: "Update from stdin pipe",
3230
+ command: "cat user.json | geonic admin users update <user-id>"
3053
3231
  }
3054
3232
  ]);
3055
3233
  const del = users.command("delete <id>").description("Delete a user").action(
@@ -3152,7 +3330,9 @@ function registerPoliciesCommand(parent) {
3152
3330
  command: "geonic admin policies get <policy-id>"
3153
3331
  }
3154
3332
  ]);
3155
- const create = policies.command("create [json]").description("Create a new policy").action(
3333
+ const create = policies.command("create [json]").description(
3334
+ 'Create a new policy\n\nJSON payload example:\n {\n "description": "Allow all entities",\n "rules": [{"ruleId": "allow-all", "effect": "Permit"}]\n }'
3335
+ ).action(
3156
3336
  withErrorHandler(async (json, _opts, cmd) => {
3157
3337
  const body = await parseJsonInput(json);
3158
3338
  const client = createClient(cmd);
@@ -3166,11 +3346,21 @@ function registerPoliciesCommand(parent) {
3166
3346
  );
3167
3347
  addExamples(create, [
3168
3348
  {
3169
- description: "Create a policy from a JSON file",
3349
+ description: "Create with inline JSON",
3350
+ command: `geonic admin policies create '{"description":"Allow all entities","rules":[{"ruleId":"allow-all","effect":"Permit"}]}'`
3351
+ },
3352
+ {
3353
+ description: "Create from a JSON file",
3170
3354
  command: "geonic admin policies create @policy.json"
3355
+ },
3356
+ {
3357
+ description: "Create from stdin pipe",
3358
+ command: "cat policy.json | geonic admin policies create"
3171
3359
  }
3172
3360
  ]);
3173
- const update = policies.command("update <id> [json]").description("Update a policy").action(
3361
+ const update = policies.command("update <id> [json]").description(
3362
+ 'Update a policy\n\nJSON payload: only specified fields are updated.\n e.g. {"description": "Updated policy"}'
3363
+ ).action(
3174
3364
  withErrorHandler(
3175
3365
  async (id, json, _opts, cmd) => {
3176
3366
  const body = await parseJsonInput(json);
@@ -3188,8 +3378,16 @@ function registerPoliciesCommand(parent) {
3188
3378
  );
3189
3379
  addExamples(update, [
3190
3380
  {
3191
- description: "Update a policy from a JSON file",
3381
+ description: "Update description",
3382
+ command: `geonic admin policies update <policy-id> '{"description":"Updated policy"}'`
3383
+ },
3384
+ {
3385
+ description: "Update from a JSON file",
3192
3386
  command: "geonic admin policies update <policy-id> @policy.json"
3387
+ },
3388
+ {
3389
+ description: "Update from stdin pipe",
3390
+ command: "cat policy.json | geonic admin policies update <policy-id>"
3193
3391
  }
3194
3392
  ]);
3195
3393
  const del = policies.command("delete <id>").description("Delete a policy").action(
@@ -3276,7 +3474,9 @@ function registerOAuthClientsCommand(parent) {
3276
3474
  command: "geonic admin oauth-clients get <client-id>"
3277
3475
  }
3278
3476
  ]);
3279
- const create = oauthClients.command("create [json]").description("Create a new OAuth client").action(
3477
+ const create = oauthClients.command("create [json]").description(
3478
+ 'Create a new OAuth client\n\nJSON payload example:\n {\n "clientName": "my-app",\n "allowedScopes": ["read:entities", "write:entities"]\n }'
3479
+ ).action(
3280
3480
  withErrorHandler(async (json, _opts, cmd) => {
3281
3481
  const body = await parseJsonInput(json);
3282
3482
  const client = createClient(cmd);
@@ -3290,11 +3490,21 @@ function registerOAuthClientsCommand(parent) {
3290
3490
  );
3291
3491
  addExamples(create, [
3292
3492
  {
3293
- description: "Create an OAuth client from a JSON file",
3493
+ description: "Create with inline JSON",
3494
+ command: `geonic admin oauth-clients create '{"clientName":"my-app","allowedScopes":["read:entities","write:entities"]}'`
3495
+ },
3496
+ {
3497
+ description: "Create from a JSON file",
3294
3498
  command: "geonic admin oauth-clients create @client.json"
3499
+ },
3500
+ {
3501
+ description: "Create from stdin pipe",
3502
+ command: "cat client.json | geonic admin oauth-clients create"
3295
3503
  }
3296
3504
  ]);
3297
- const update = oauthClients.command("update <id> [json]").description("Update an OAuth client").action(
3505
+ const update = oauthClients.command("update <id> [json]").description(
3506
+ 'Update an OAuth client\n\nJSON payload: only specified fields are updated.\n e.g. {"description": "Updated client"}'
3507
+ ).action(
3298
3508
  withErrorHandler(
3299
3509
  async (id, json, _opts, cmd) => {
3300
3510
  const body = await parseJsonInput(json);
@@ -3312,8 +3522,16 @@ function registerOAuthClientsCommand(parent) {
3312
3522
  );
3313
3523
  addExamples(update, [
3314
3524
  {
3315
- description: "Update an OAuth client from a JSON file",
3525
+ description: "Update description",
3526
+ command: `geonic admin oauth-clients update <client-id> '{"description":"Updated client"}'`
3527
+ },
3528
+ {
3529
+ description: "Update from a JSON file",
3316
3530
  command: "geonic admin oauth-clients update <client-id> @client.json"
3531
+ },
3532
+ {
3533
+ description: "Update from stdin pipe",
3534
+ command: "cat client.json | geonic admin oauth-clients update <client-id>"
3317
3535
  }
3318
3536
  ]);
3319
3537
  const del = oauthClients.command("delete <id>").description("Delete an OAuth client").action(
@@ -3349,7 +3567,9 @@ function registerCaddeCommand(parent) {
3349
3567
  command: "geonic admin cadde get"
3350
3568
  }
3351
3569
  ]);
3352
- const caddeSet = cadde.command("set [json]").description("Set CADDE configuration").action(
3570
+ const caddeSet = cadde.command("set [json]").description(
3571
+ 'Set CADDE configuration\n\nJSON payload example:\n {\n "provider": "my-provider",\n "endpoint": "http://localhost:6000"\n }'
3572
+ ).action(
3353
3573
  withErrorHandler(async (json, _opts, cmd) => {
3354
3574
  const body = await parseJsonInput(json);
3355
3575
  const client = createClient(cmd);
@@ -3363,8 +3583,16 @@ function registerCaddeCommand(parent) {
3363
3583
  );
3364
3584
  addExamples(caddeSet, [
3365
3585
  {
3366
- description: "Set CADDE configuration from a JSON file",
3586
+ description: "Set with inline JSON",
3587
+ command: `geonic admin cadde set '{"provider":"my-provider","endpoint":"http://localhost:6000"}'`
3588
+ },
3589
+ {
3590
+ description: "Set from a JSON file",
3367
3591
  command: "geonic admin cadde set @cadde-config.json"
3592
+ },
3593
+ {
3594
+ description: "Set from stdin pipe",
3595
+ command: "cat cadde-config.json | geonic admin cadde set"
3368
3596
  }
3369
3597
  ]);
3370
3598
  const caddeDelete = cadde.command("delete").description("Delete CADDE configuration").action(
@@ -3624,7 +3852,9 @@ function registerRulesCommand(program2) {
3624
3852
  command: "geonic rules get <rule-id>"
3625
3853
  }
3626
3854
  ]);
3627
- const create = rules.command("create [json]").description("Create a new rule").action(
3855
+ const create = rules.command("create [json]").description(
3856
+ 'Create a new rule\n\nJSON payload example:\n {\n "name": "high-temp-alert",\n "description": "Alert on high temperature",\n "conditions": [{"type": "celExpression", "expression": "entity.temperature > 30"}],\n "actions": [{"type": "webhook", "url": "http://localhost:5000/alert", "method": "POST"}]\n }'
3857
+ ).action(
3628
3858
  withErrorHandler(async (json, _opts, cmd) => {
3629
3859
  const body = await parseJsonInput(json);
3630
3860
  const client = createClient(cmd);
@@ -3636,11 +3866,21 @@ function registerRulesCommand(program2) {
3636
3866
  );
3637
3867
  addExamples(create, [
3638
3868
  {
3639
- description: "Create a rule from a file",
3869
+ description: "Create with inline JSON",
3870
+ command: `geonic rules create '{"name":"high-temp-alert","conditions":[{"type":"celExpression","expression":"entity.temperature > 30"}],"actions":[{"type":"webhook","url":"http://localhost:5000/alert","method":"POST"}]}'`
3871
+ },
3872
+ {
3873
+ description: "Create from a file",
3640
3874
  command: "geonic rules create @rule.json"
3875
+ },
3876
+ {
3877
+ description: "Create from stdin pipe",
3878
+ command: "cat rule.json | geonic rules create"
3641
3879
  }
3642
3880
  ]);
3643
- const update = rules.command("update <id> [json]").description("Update a rule").action(
3881
+ const update = rules.command("update <id> [json]").description(
3882
+ 'Update a rule\n\nJSON payload: only specified fields are updated.\n e.g. {"description": "Updated rule"}'
3883
+ ).action(
3644
3884
  withErrorHandler(
3645
3885
  async (id, json, _opts, cmd) => {
3646
3886
  const body = await parseJsonInput(json);
@@ -3658,8 +3898,16 @@ function registerRulesCommand(program2) {
3658
3898
  );
3659
3899
  addExamples(update, [
3660
3900
  {
3661
- description: "Update a rule from a file",
3901
+ description: "Update description",
3902
+ command: `geonic rules update <rule-id> '{"description":"Updated rule"}'`
3903
+ },
3904
+ {
3905
+ description: "Update from a file",
3662
3906
  command: "geonic rules update <rule-id> @rule.json"
3907
+ },
3908
+ {
3909
+ description: "Update from stdin pipe",
3910
+ command: "cat rule.json | geonic rules update <rule-id>"
3663
3911
  }
3664
3912
  ]);
3665
3913
  const del = rules.command("delete <id>").description("Delete a rule").action(
@@ -3746,7 +3994,9 @@ function registerModelsCommand(program2) {
3746
3994
  command: "geonic models get <model-id>"
3747
3995
  }
3748
3996
  ]);
3749
- const create = models.command("create [json]").description("Create a new model").action(
3997
+ const create = models.command("create [json]").description(
3998
+ 'Create a new model\n\nJSON payload example:\n {\n "type": "Sensor",\n "domain": "iot",\n "description": "IoT Sensor",\n "propertyDetails": {\n "temperature": {"ngsiType": "Property", "valueType": "Number", "example": 25}\n }\n }'
3999
+ ).action(
3750
4000
  withErrorHandler(async (json, _opts, cmd) => {
3751
4001
  const body = await parseJsonInput(json);
3752
4002
  const client = createClient(cmd);
@@ -3758,11 +4008,21 @@ function registerModelsCommand(program2) {
3758
4008
  );
3759
4009
  addExamples(create, [
3760
4010
  {
3761
- description: "Create a model from a file",
4011
+ description: "Create with inline JSON",
4012
+ command: `geonic models create '{"type":"Sensor","domain":"iot","description":"IoT Sensor","propertyDetails":{"temperature":{"ngsiType":"Property","valueType":"Number","example":25}}}'`
4013
+ },
4014
+ {
4015
+ description: "Create from a file",
3762
4016
  command: "geonic models create @model.json"
4017
+ },
4018
+ {
4019
+ description: "Create from stdin pipe",
4020
+ command: "cat model.json | geonic models create"
3763
4021
  }
3764
4022
  ]);
3765
- const update = models.command("update <id> [json]").description("Update a model").action(
4023
+ const update = models.command("update <id> [json]").description(
4024
+ 'Update a model\n\nJSON payload: only specified fields are updated.\n e.g. {"description": "Updated model"}'
4025
+ ).action(
3766
4026
  withErrorHandler(
3767
4027
  async (id, json, _opts, cmd) => {
3768
4028
  const body = await parseJsonInput(json);
@@ -3780,8 +4040,16 @@ function registerModelsCommand(program2) {
3780
4040
  );
3781
4041
  addExamples(update, [
3782
4042
  {
3783
- description: "Update a model from a file",
4043
+ description: "Update description",
4044
+ command: `geonic models update <model-id> '{"description":"Updated description"}'`
4045
+ },
4046
+ {
4047
+ description: "Update from a file",
3784
4048
  command: "geonic models update <model-id> @model.json"
4049
+ },
4050
+ {
4051
+ description: "Update from stdin pipe",
4052
+ command: "cat model.json | geonic models update <model-id>"
3785
4053
  }
3786
4054
  ]);
3787
4055
  const del = models.command("delete <id>").description("Delete a model").action(