@rbxts/centurion-ui 2.0.0-rc.2 → 2.0.0-rc.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/app/init.luau +15 -8
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rbxts/centurion-ui",
3
3
  "description": "Terminal UI for the Centurion command framework",
4
- "version": "2.0.0-rc.2",
4
+ "version": "2.0.0-rc.3",
5
5
  "author": "paradoxuum",
6
6
  "license": "MIT",
7
7
  "main": "src/ts/init.luau",
package/src/app/init.luau CHANGED
@@ -315,9 +315,11 @@ local function app()
315
315
  end)
316
316
 
317
317
  local function submit(value: string)
318
+ local trimmed = value:gsub("^%s*(.-)%s*$", "%1")
319
+
318
320
  -- resolve from the submitted text rather than the analysis, which only
319
321
  -- carries arguments when the cursor happens to sit on one
320
- local submitted = centurion.resolve_command(value)
322
+ local submitted = centurion.resolve_command(trimmed)
321
323
  raw_text("")
322
324
  analysis(default_analysis)
323
325
 
@@ -334,11 +336,16 @@ local function app()
334
336
  end
335
337
 
336
338
  cmd_history_index = 0
337
- table.insert(cmd_history, 1, value)
339
+
340
+ local history_index = table.find(cmd_history, trimmed)
341
+ if history_index ~= nil then
342
+ table.remove(cmd_history, history_index)
343
+ end
344
+ table.insert(cmd_history, 1, trimmed)
338
345
 
339
346
  local cmd = submitted.name
340
347
  if not cmd then
341
- log(value, {
348
+ log(trimmed, {
342
349
  success = false,
343
350
  message = "Unknown command",
344
351
  timestamp = os.time(),
@@ -350,12 +357,12 @@ local function app()
350
357
  executing(executing() + 1)
351
358
 
352
359
  -- pass the submitted text so that ctx.input keeps its original quoting
353
- local ok, result = pcall(centurion.execute_command, Players.LocalPlayer, cmd, submitted.args, value)
360
+ local ok, result = pcall(centurion.execute_command, Players.LocalPlayer, cmd, submitted.args, trimmed)
354
361
  executing(executing() - 1)
355
362
 
356
363
  if not ok then
357
- warn(`Failed to execute '{value}': {result}`)
358
- log(value, {
364
+ warn(`Failed to execute '{trimmed}': {result}`)
365
+ log(trimmed, {
359
366
  success = false,
360
367
  message = "Failed to execute command",
361
368
  timestamp = os.time(),
@@ -365,10 +372,10 @@ local function app()
365
372
 
366
373
  if result.response then
367
374
  if result.response.message ~= "" then
368
- log(value, result.response)
375
+ log(trimmed, result.response)
369
376
  end
370
377
  else
371
- log(value, {
378
+ log(trimmed, {
372
379
  success = true,
373
380
  message = "Command executed",
374
381
  timestamp = os.time(),