/// <summary> /// Configure the builder by default from attributes. /// </summary> /// <param name="builder"></param> /// <param name="type"></param> /// <returns></returns> public static ICommandLineModuleManifestBuilder WithDefaultsFromModuleType(this ICommandLineModuleManifestBuilder builder, Type type) { if (type.IsDefined(typeof(CommandsFromAssemblyAttribute))) { builder.WithCommandsFromModuleAssembly(type); } var cmdAttrs = type.GetCustomAttributes <CommandFromAttribute>(true); foreach (var attr in cmdAttrs) { builder.AddCommand(attr.Type); } return(builder); }
/// <summary> /// Add a command type to manifest. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="builder"></param> /// <returns></returns> public static ICommandLineModuleManifestBuilder AddCommand <T>(this ICommandLineModuleManifestBuilder builder) where T : ICommand => builder.AddCommand(typeof(T));