百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

cmd

> 编程语言
开源

用于以更简单的方式运行外部程序的 C# 库。展示 C# 的"动态"功能。

361 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于以更简单的方式运行外部程序的 C# 库。展示 C# 的"动态"功能。

cmd

A C# Library to run external programs / commands in a simpler way. It is inspired from the sh library for Python, and is intended to showcase the "dynamic" features of C#

How to get it?

Cmd is available through the Nuget Package Manager.

Or, you can build it from source.

How to use it?

Create a dynamic instance of Cmd:

csharp
dynamic cmd = new Cmd();

Now, you can call commands off cmd:

csharp
cmd.git.clone("http://github.com/manojlds/cmd");

The above would be equivalent to git clone http://github.com/manojlds/cmd.

You can pass flags by naming the arguments:

csharp
cmd.git.log(grep: "test");

The above would be equivalent to git log --grep test

Or:

csharp
cmd.git.branch(a: true);

which would be equivalent to git branch -a

Note that single character flags are mapped as - and multi-character ones are mapped as --

Also, non-string values are ignored and if there is no flag, the argument is not considered.

You can call multiple commands off the same instance of cmd:

csharp
var gitOutput = cmd.git();
var svnOutput = cmd.svn();

Note that the commands can be case sensitive, and as such cmd.git is not same as, say, cmd.Git.

How to set environment variables?

Environment variables can be set for the process by calling ._Env method on an instance of Cmd and pass the set of environment variables with their values as a Dictionary:

csharp
cmd._Env(new Dictionary { { "GIT_DIR", @"C:\" } });

Note that this replaces existing variables with the new values.

Shells

You can use cmd to run command on, well, cmd and Powershell. Choose the shell you want to use while creating cmd:

csharp
dynamic cmd = new Cmd(Shell.Cmd);
dynamic posh = new Cmd(Shell.Powershell);
cmd.dir();

cmd.dir() is equivalent to cmd /c dir

When using Shell.Cmd, flags are constructed using / instead of - and --

Powershell support is still a work in progress.

What's ahead?

cmd is in a very nascent stage. More sh like goodness coming soon.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言