stillwwater / command_terminal

Unity Command Terminal: In-Game Console
MIT License
445 stars 60 forks source link

Command groups idea #4

Open Wokarol opened 6 years ago

Wokarol commented 6 years ago

So I was asked to move this here:

•Can you add something like "command groups" so when I have bunch of objects with similar commands like "testcube.jump" they won't show in help menu?

stillwwater commented 6 years ago

What about prefixing the help string with a group name? Something like:

[RegisterCommand("cube.move", Help = "cube/Move test cube")]
static void CommandMove(CommandArg[] args) { }

[RegisterCommand("cube.rotate", Help = "cube/Rotate test cube")]
static void CommandRotate(CommandArg[] args) { }

Then calling the help command would only show "cube", and calling help cube would list all commands in the group.

That way this is only a documentation thing, and doesn't affect how commands are processed internally. Allowing it to be an optional feature.

Either way I think you make a valid point, my projects use enough commands that the help command isn't super useful, and I find my self using help command_name most of the time. Having groups would likely make the command documentation more organized and easier to navigate.

Wokarol commented 6 years ago

That would work, especially with new autocomplete

stillwwater commented 6 years ago

I've added this functionality to the help command. Example using ed as a group:

screenshot

Wokarol commented 6 years ago

How about adding option not to create a help menu for command? For example I have 3 objects and every object creates command with name "{name}.jump" and I don't want to show any of this groups in help menu?

stillwwater commented 6 years ago

So just a way to not show the command at all?

Also, why create a jump command for each object instead of having a single jump command that receives an identifier like jump {name}?

Wokarol commented 6 years ago

Because I don't need to create one object to hold all objects with jump command, instead every object can add it's own command, and autocomplete supports it. When I think of it I can create static class to store objects which is good but there is still no autocomplete support.

stillwwater commented 6 years ago

Ah that makes sense, the groups would allow you to group all {name} objects together or all jump commands together. Why would you want to hide everything?

Something like:

[RegisterCommand("cube1.jump", Help = "jump/Cube1 jump")]
static void CommandJump1(CommandArg[] args) { }

[RegisterCommand("cube2.jump", Help = "jump/Cube2 jump")]
static void CommandJump2(CommandArg[] args) { }

would only show jump (not the individual cube.jump commands) in the help list, to see both commands you would use help jump.

By the way, you can add things to the autocomplete with Terminal.Autocomplete.Register("name"). But I get what you're saying, you want separate commands.

Wokarol commented 6 years ago

Making command structure like {object}.{group}.{command} is just more logical to me. equipment.gear.add helmet is more logical to me than add equipment gear helmet or equipment_add gear helmet

Wokarol commented 6 years ago

But after some thought jump {name} might be more logical

AmAutoma commented 5 years ago

I've added this functionality to the help command. Example using ed as a group:

screenshot

Excuse me, is this already available?