public CliExecutorDescriptor Build() { var topDefblock = _form.Single(x => x.GetSingleArgumentAsBool(":is-top") ?? false); var supposedCommandForm = topDefblock.GetFreeArguments().First(); if (supposedCommandForm.GetCarSymbolName().ToLowerInvariant() != "executor") { throw new CliException($"'executor' symbol was expected."); } var name = supposedCommandForm.GetSingleKeywordArgument <Symbol>(":executor-name", true)?.Name; var verb = supposedCommandForm.GetSingleKeywordArgument <StringAtom>(":verb", true)?.Value; var description = supposedCommandForm.GetSingleKeywordArgument <StringAtom>(":description", true)?.Value; var usageSamples = supposedCommandForm.GetSingleKeywordArgument(":usage-samples", true)? .AsPseudoList()? .Cast <StringAtom>() .Select(x => x.Value) .ToList(); var keyList = new List <CliExecutorKeyDescriptor>(); var argumentList = new List <CliExecutorArgumentDescriptor>(); var optionList = new List <CliExecutorOptionDescriptor>(); this.CollectItems( topDefblock.AsPseudoList().GetFreeArguments(), keyList, argumentList, optionList); var descriptor = new CliExecutorDescriptor( name, verb, description, usageSamples, keyList, argumentList, optionList); return(descriptor); }