Orchard为许多在管理面板中可用的和不可用的功能的命令行接口。命令行工具名称是 “orchard.exe”,在网站根目录下bin目录中。
Using Commands
要查看可用的命令,输入help commands。
orchard> help commands
List of available commands:
---------------------------blog create /Slug:<slug> /Title:<title> /Owner:<username> [/MenuText:<menu text>]Creates a new Blogblog import /Slug:<slug> /FeedUrl:<feed url> /Owner:<username>Import all items from <feed url> into the blog at the specified <slug>cultures get site cultureGet culture for the sitecultures listList site culturescultures set site culture <culture-name>Set culture for the sitefeature disable <feature-name-1> ... <feature-name-n>Disable one or more featuresfeature enable <feature-name-1> ... <feature-name-n>Enable one or more featuresfeature list [/Summary:true|false]Display list of available featureshelp <command>Display help text for <command>help commandsDisplay help text for all available commandspackage create <extensionName> <path>Create a package for the extension <extensionName>(an extension being a module or a theme).The package will be output at the <path> specified.The default filename is Orchard.[Module|Theme].<extensionName>.<extensionVersion>.nupkg.For example, "package create SampleModule c:\temp" will create the package"c:\temp\Orchard.Module.SampleModule.1.0.0.nupkg".package install <packageId> <location> /Version:<version>Install a module or a theme from a package file.package uninstall <packageId>Uninstall a module or a theme.The <packageId> should take the format Orchard.[Module|Theme].<extensionName>.For example, "package uninstall Orchard.Module.SampleModule" will uninstall the Module under the "~/Modules/SampleModule" directory and"package uninstall Orchard.Theme.SampleTheme" will uninstall the Theme under the "~/Themes/SampleTheme" directory.user create /UserName:<username> /Password:<password> /Email:<email>Creates a new User
可用的命令依赖网站中启用的功能。输入feature list可以列出功能列表,并且可以禁用和启用相应的功能。在命令行输入feature enable/disable <feature-name>,启用或禁用
orchard> feature list /Summary:true
Common, Enabled
Containers, Enabled
Contents, Enabled
Dashboard, Enabled
DatabaseUpdate, Disabled
Feeds, Enabled
Gallery, Enabled
HomePage, Enabled
Lucene, Disabled
Navigation, Enabled
Orchard.ArchiveLater, Disabled
Orchard.Blogs, Enabled
Orchard.Blogs.RemotePublishing, Disabled
Orchard.CodeGeneration, Enabled
Orchard.Comments, Enabled
Orchard.ContentTypes, Enabled
Orchard.Email, Disabled
Orchard.Experimental, Disabled
Orchard.Experimental.TestingLists, Disabled
Orchard.Experimental.WebCommandLine, Disabled
Orchard.Indexing, Disabled
Orchard.jQuery, Enabled
Orchard.Lists, Enabled
Orchard.Localization, Disabled
Orchard.Media, Enabled
Orchard.Messaging, Disabled
Orchard.Migrations, Disabled
Orchard.Modules, Enabled
Orchard.MultiTenancy, Disabled
Orchard.Packaging, Enabled
Orchard.Pages, Enabled
Orchard.PublishLater, Enabled
Orchard.Roles, Enabled
Orchard.Scripting, Enabled
Orchard.Scripting.Dlr, Disabled
Orchard.Scripting.Lightweight, Enabled
Orchard.Search, Disabled
Orchard.Setup, Disabled
Orchard.Tags, Enabled
Orchard.Themes, Enabled
Orchard.Users, Enabled
Orchard.Widgets, Enabled
PackagingServices, Enabled
Profiling, Disabled
Reports, Enabled
Routable, Enabled
SafeMode, Disabled
Scheduling, Enabled
Settings, Enabled
Shapes, Enabled
TheAdmin, Disabled
TheThemeMachine, Enabled
TinyMce, Enabled
XmlRpc, Disabled
Adding Commands
模块开发者能添加自己的命令,需要从Orchard.Commands.DefaultOrchardCommandHandler实现一个新类。一个命令就是一个类中的拥有CommandName特性的方法。下面创建hello world命令:
[CommandName("hello world")]
[CommandHelp(@"hello world <name> [/YouRock:true|false]
Says hello and whether you rock or not.")]
[OrchardSwitches("YouRock")]
public void HelloWorld(string name) {Context.Output.WriteLine(T("Hello {0}.", name ?? "world"));Context.Output.WriteLine(YouRock ? "You rock." : "You do not rock.");
}
The switch itself is declared as a property of the class:
[OrchardSwitch]
public bool YouRock { get; set; }