use of act.cli.CliContext in project actframework by actframework.
the class CliOverHttp method run.
@PostAction("cmd")
public Result run(String cmd, ActionContext context) throws IOException {
CliHandler handler = handler(cmd);
ByteArrayOutputStream os = new ByteArrayOutputStream();
CliContext cliContext = new CliOverHttpContext(context, os);
handler.handle(cliContext);
cliContext.flush();
String txt = new String(os.toByteArray(), "UTF-8");
txt = txt.replace("^J", "\n");
return text(txt);
}
use of act.cli.CliContext in project actframework by actframework.
the class RequestScope method put.
public <T> void put(String key, T t) {
if (null == t) {
return;
}
ActionContext actionContext = ActionContext.current();
if (null != actionContext) {
actionContext.attribute(key, t);
}
CliContext cliContext = CliContext.current();
if (null != cliContext) {
cliContext.attribute(key, t);
}
}
use of act.cli.CliContext in project actframework by actframework.
the class CliVarArgumentLoader method load.
@Override
public Object load(Object cached, ActContext<?> context, boolean noDefaultValue) {
CliContext ctx = (CliContext) context;
List list = new ArrayList();
CliContext.ParsingContext parsingContext = ctx.parsingContext();
CommandLineParser parser = ctx.commandLine();
while (parsingContext.hasArguments(parser)) {
int id = ctx.parsingContext().curArgId().getAndIncrement();
list.add(resolver.resolve(parser.argument(id)));
}
return ArrayLoader.listToArray(list, componentType);
}
Aggregations