I think the key is to understand that once you press 'TEST ' (with the trailing space) the command is launched and you are already inside your function.
From there you must mimic the options management.
If your command will have a graphics interaction, like getting a point, the best solution is to set keyword options in the same prompt, because it will work exactly as AutoCAD native commands.
For Example, here I want to select a polyline, but also allow for keyword actions:
// set defaults
PromptDoubleOptions optVal = new PromptDoubleOptions("");
PromptDoubleResult res_double;
PromptEntityResult res;
while (true)
{
String szMessage = String.Format("\nSelect polyline or [Radius={0}/Width={1}/Xhatch={2}/Keep={3}]:",
dRad, dThick, (bDrawHatch ? "S" : "N"), (bKeepPline ? "S" : "N"));
// get Polyline or keywords
PromptEntityOptions opt = new PromptEntityOptions(szMessage, "Radius Width Xhatch Keep");
opt.SetRejectMessage("** not a polyline **");
opt.AddAllowedClass(typeof(Polyline), true);
res = ed.GetEntity(opt);
if (res.Status == PromptStatus.OK)
{
// execute the command with current parameters
if (DoLamiere(res.ObjectId, dRad, dThick, bDrawHatch, false, bKeepPline) == true)
{
csProfili.SaveCurrentParameters(csProfili.SECT_LAMIERE, dRad, dThick, 0.0, bDrawHatch, bKeepPline, 0);
}
}
else if (res.Status == PromptStatus.Keyword)
{
switch (res.StringResult.ToUpperInvariant())
{
case "RADIUS":
// ask for new fillet radius
optVal.Message = "\nInternal bending radius";
optVal.AllowZero = true;
optVal.DefaultValue = dRad;
optVal.UseDefaultValue = true;
res_double = ed.GetDouble(optVal);
if (res_double.Status == PromptStatus.OK) dRad = res_double.Value;
break;
case "WIDTH":
// ask for new width
optVal.Message = "\nWidth";
optVal.AllowZero = false;
optVal.DefaultValue = dThick;
optVal.UseDefaultValue = true;
res_double = ed.GetDouble(optVal);
if (res_double.Status == PromptStatus.OK) dThick = res_double.Value;
break;
case "XHATCH":
// Flag: draw xh or not
bDrawHatch = !bDrawHatch;
break;
case "KEEP":
// Flag: keep original polyline or discard
bKeepPline = !bKeepPline;
break;
}
}
else
break; // command aborted, exit main loop
}
If you use JIG function, keywords are also available, see JigPromptPointOptions.SetMessageAndKeywords().
If you don't have an interactive session, I'm afraid you should mimic a text input and process it. The only not-standard behavior is that for empty parameters you need an additional space or enter to actually run the command. Maybe you may display default values to let the user know he/she needs another Enter to actually start the command.