"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[7400],{5781:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>t,contentTitle:()=>o,default:()=>j,frontMatter:()=>d,metadata:()=>c,toc:()=>h});var s=r(5893),l=r(1151),i=r(4996);const d={id:"dotnet-tools",title:"37. \u7f16\u5199\u5305\u7ba1\u7406\u5de5\u5177",sidebar_label:"37. \u7f16\u5199\u5305\u7ba1\u7406\u5de5\u5177 (Tools)"},o=void 0,c={id:"dotnet-tools",title:"37. \u7f16\u5199\u5305\u7ba1\u7406\u5de5\u5177",description:"37.1 \u5173\u4e8e\u5305\u7ba1\u7406\u5de5\u5177",source:"@site/docs/dotnet-tools.mdx",sourceDirName:".",slug:"/dotnet-tools",permalink:"/docs/dotnet-tools",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/dotnet-tools.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1698606538,formattedLastUpdatedAt:"Oct 29, 2023",frontMatter:{id:"dotnet-tools",title:"37. \u7f16\u5199\u5305\u7ba1\u7406\u5de5\u5177",sidebar_label:"37. \u7f16\u5199\u5305\u7ba1\u7406\u5de5\u5177 (Tools)"},sidebar:"docs",previous:{title:"36.4 \u5e76\u53d1\u6d4b\u8bd5",permalink:"/docs/bingfa"},next:{title:"38. \u8d21\u732e\u6307\u5357",permalink:"/docs/contribute"}},t={},h=[{value:"37.1 \u5173\u4e8e\u5305\u7ba1\u7406\u5de5\u5177",id:"371-\u5173\u4e8e\u5305\u7ba1\u7406\u5de5\u5177",level:2},{value:"37.1.1 dotnet tools \u5305\u7ba1\u7406\u597d\u5904",id:"3711-dotnet-tools-\u5305\u7ba1\u7406\u597d\u5904",level:3},{value:"37.2 \u4e86\u89e3\u5305\u547d\u4ee4\u8bed\u6cd5",id:"372-\u4e86\u89e3\u5305\u547d\u4ee4\u8bed\u6cd5",level:2},{value:"37.2.1 \u77ed\u53c2\u6570\u4f8b\u5b50",id:"3721-\u77ed\u53c2\u6570\u4f8b\u5b50",level:3},{value:"37.2.2 \u957f\u53c2\u6570\u4f8b\u5b50",id:"3722-\u957f\u53c2\u6570\u4f8b\u5b50",level:3},{value:"37.2.3 \u6df7\u5408\u53c2\u6570\u4f8b\u5b50",id:"3723-\u6df7\u5408\u53c2\u6570\u4f8b\u5b50",level:3},{value:"37.2.4 \u591a\u4e2a\u503c\u53c2\u6570",id:"3724-\u591a\u4e2a\u503c\u53c2\u6570",level:3},{value:"37.2.5 \u64cd\u4f5c\u7b26",id:"3725-\u64cd\u4f5c\u7b26",level:3},{value:"37.3 \u7f16\u5199\u7b2c\u4e00\u4e2a\u5305",id:"373-\u7f16\u5199\u7b2c\u4e00\u4e2a\u5305",level:2},{value:"37.3.1 \u521b\u5efa HelloTools \u63a7\u5236\u53f0\u5e94\u7528",id:"3731-\u521b\u5efa-hellotools-\u63a7\u5236\u53f0\u5e94\u7528",level:3},{value:"37.3.2 \u7f16\u8f91 HelloTools.csproj",id:"3732-\u7f16\u8f91-hellotoolscsproj",level:3},{value:"\u914d\u7f6e\u5173\u952e\u8282\u70b9\u8bf4\u660e",id:"\u914d\u7f6e\u5173\u952e\u8282\u70b9\u8bf4\u660e",level:4},{value:"37.3.3 \u5b89\u88c5 Furion.Tools.CommandLine \u5305",id:"3733-\u5b89\u88c5-furiontoolscommandline-\u5305",level:3},{value:"37.3.4 \u7f16\u5199\u903b\u8f91\u4ee3\u7801",id:"3734-\u7f16\u5199\u903b\u8f91\u4ee3\u7801",level:3},{value:"37.3.5 \u5982\u4f55\u8c03\u8bd5\u5305\u5de5\u5177 \ud83d\udc4f",id:"3735-\u5982\u4f55\u8c03\u8bd5\u5305\u5de5\u5177-",level:3},{value:"37.3.6 \u6d4b\u8bd5\u5404\u4e2a\u53c2\u6570\u60c5\u51b5",id:"3736-\u6d4b\u8bd5\u5404\u4e2a\u53c2\u6570\u60c5\u51b5",level:3},{value:"37.4 \u6253\u5305\uff08\u672c\u673a\uff09\u6d4b\u8bd5",id:"374-\u6253\u5305\u672c\u673a\u6d4b\u8bd5",level:2},{value:"37.4.1 \u5168\u5c40\u6253\u5305\u5b89\u88c5",id:"3741-\u5168\u5c40\u6253\u5305\u5b89\u88c5",level:3},{value:"\u2714 \u5b89\u88c5\u5168\u5c40\u5305",id:"-\u5b89\u88c5\u5168\u5c40\u5305",level:4},{value:"\u2714 \u6d4b\u8bd5\u5168\u5c40\u5305",id:"-\u6d4b\u8bd5\u5168\u5c40\u5305",level:4},{value:"\u2714 \u66f4\u65b0\u5168\u5c40\u5305",id:"-\u66f4\u65b0\u5168\u5c40\u5305",level:4},{value:"\u2714 \u5378\u8f7d\u5168\u5c40\u5305",id:"-\u5378\u8f7d\u5168\u5c40\u5305",level:4},{value:"37.4.2 \u672c\u5730\u6253\u5305\u5b89\u88c5",id:"3742-\u672c\u5730\u6253\u5305\u5b89\u88c5",level:3},{value:"\u2714 \u521b\u5efa\u672c\u5730\u6e05\u5355\u6587\u4ef6",id:"-\u521b\u5efa\u672c\u5730\u6e05\u5355\u6587\u4ef6",level:4},{value:"\u2714 \u5b89\u88c5\u672c\u5730\u5305",id:"-\u5b89\u88c5\u672c\u5730\u5305",level:4},{value:"\u2714 \u6d4b\u8bd5\u672c\u5730\u5305",id:"-\u6d4b\u8bd5\u672c\u5730\u5305",level:4},{value:"\u2714 \u66f4\u65b0\u672c\u5730\u5305",id:"-\u66f4\u65b0\u672c\u5730\u5305",level:4},{value:"\u2714 \u5378\u8f7d\u672c\u5730\u5305",id:"-\u5378\u8f7d\u672c\u5730\u5305",level:4},{value:"37.5 \u53d1\u5e03\u5230 NuGet \u5e73\u53f0 \ud83d\udc4f",id:"375-\u53d1\u5e03\u5230-nuget-\u5e73\u53f0-",level:2},{value:"\u2714 \u5b89\u88c5 NuGet \u5305\u5230\u672c\u5730",id:"-\u5b89\u88c5-nuget-\u5305\u5230\u672c\u5730",level:4},{value:"37.6 Cli \u9759\u6001\u7c7b\u8bf4\u660e",id:"376-cli-\u9759\u6001\u7c7b\u8bf4\u660e",level:2},{value:"37.6.1 \u6d88\u606f\u7c7b",id:"3761-\u6d88\u606f\u7c7b",level:3},{value:"37.6.2 \u5de5\u5177\u7c7b",id:"3762-\u5de5\u5177\u7c7b",level:3},{value:"37.6.2 \u4fe1\u606f\u7c7b",id:"3762-\u4fe1\u606f\u7c7b",level:3},{value:"37.6.3 \u5176\u4ed6\u7c7b",id:"3763-\u5176\u4ed6\u7c7b",level:3},{value:"37.7 \u96c6\u6210 Spectre.Console",id:"377-\u96c6\u6210-spectreconsole",level:2},{value:"37.8 \u96c6\u6210 CliWrap",id:"378-\u96c6\u6210-cliwrap",level:2},{value:"37.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"379-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function a(e){const n={a:"a",admonition:"admonition",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",h4:"h4",li:"li",mdxAdmonitionTitle:"mdxAdmonitionTitle",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h2,{id:"371-\u5173\u4e8e\u5305\u7ba1\u7406\u5de5\u5177",children:"37.1 \u5173\u4e8e\u5305\u7ba1\u7406\u5de5\u5177"}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528\u8fc7 ",(0,s.jsx)(n.code,{children:"NodeJs"})," \u7684\u670b\u53cb\u4e00\u5b9a\u5bf9 ",(0,s.jsx)(n.code,{children:"npm"})," \u547d\u4ee4\u4e0d\u4f1a\u964c\u751f\uff0c\u53ef\u4ee5\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"npm"})," \u5b89\u88c5\u9879\u76ee\u9700\u8981\u7684\u5305\u6216\u73af\u5883\u9700\u8981\u7684\u5de5\u5177\uff0c\u5728 ",(0,s.jsx)(n.code,{children:".NET Core 2.1+"})," \u4e4b\u540e\uff0c\u5fae\u8f6f\u4e5f\u63a8\u51fa\u4e86\u65b0\u7684\u7279\u6027\uff0c",(0,s.jsx)(n.code,{children:"Global/Local Tools"}),"\uff0c\u8be5\u7279\u6027\u529f\u80fd\u4e5f\u6b63\u662f\u53d7\u5230 ",(0,s.jsx)(n.code,{children:"npm"})," \u542f\u53d1\u4e0b\u8bde\u751f\u7684\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0d\u540c\u7684\u662f\uff0c",(0,s.jsx)(n.code,{children:"npm"})," \u4e2d\u7684\u5305\u91c7\u7528\u7684\u662f ",(0,s.jsx)(n.code,{children:"JavaScript"})," \u7f16\u5199\u5e76\u53d1\u5e03\u5230 ",(0,s.jsx)(n.a,{href:"https://www.npmjs.com/",children:"https://www.npmjs.com/"})," \u5e73\u53f0\uff0c\u800c ",(0,s.jsx)(n.code,{children:"dotnet tools"})," \u91c7\u7528 ",(0,s.jsx)(n.code,{children:"C#"})," \u7f16\u5199\u5e76\u53d1\u5e03\u5230 ",(0,s.jsx)(n.code,{children:"https://www.nuget.org/"})," \u5e73\u53f0\u4f9b\u5b89\u88c5\u4f7f\u7528\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"3711-dotnet-tools-\u5305\u7ba1\u7406\u597d\u5904",children:["37.1.1 ",(0,s.jsx)(n.code,{children:"dotnet tools"})," \u5305\u7ba1\u7406\u597d\u5904"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u8de8\u5e73\u53f0\uff0c\u652f\u6301 ",(0,s.jsx)(n.code,{children:"Linux/Mac/Windows"})," \u5e73\u53f0\u4f9b\u5b89\u88c5\u4f7f\u7528"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5b8c\u6574\u7684 ",(0,s.jsx)(n.code,{children:"C#"})," \u751f\u6001\u652f\u6301"]}),"\n",(0,s.jsx)(n.li,{children:"\u4e3a\u6240\u6b32\u4e3a~~~\uff08\u62e5\u6709\u64cd\u4f5c\u7cfb\u7edf\u7684\u6743\u9650\uff09"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"372-\u4e86\u89e3\u5305\u547d\u4ee4\u8bed\u6cd5",children:"37.2 \u4e86\u89e3\u5305\u547d\u4ee4\u8bed\u6cd5"}),"\n",(0,s.jsx)(n.p,{children:"\u901a\u5e38\u5305\u547d\u4ee4\u8bed\u6cd5\u90fd\u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"<-|--|/>argument-name<=|:| >[\"|']value['|\"] [--] [operand] ... [operand]\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u8fd9\u91cc\uff0c",(0,s.jsx)(n.code,{children:"Furion"})," \u5c06\u7b80\u5355\u4ecb\u7ecd\u547d\u4ee4\u5e38\u7528\u7684\u77e5\u8bc6\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"\u5de5\u5177\u7b26"}),"\uff1a\u901a\u5e38\u6307\u7684\u662f\u4f60\u5de5\u5177\u7684\u552f\u4e00\u540d\u79f0\uff0c\u4e5f\u5c31\u662f\u5173\u952e\u5b57\uff0c\u800c\u4e14\u603b\u662f\u5728\u6700\u5f00\u5934\u7f16\u5199\uff0c\u5982\uff1a",(0,s.jsx)(n.code,{children:"dotnet"}),"\uff0c",(0,s.jsx)(n.code,{children:"npm"}),"\uff0c",(0,s.jsx)(n.code,{children:"node"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"\u77ed\u53c2\u6570"}),"\uff1a\u77ed\u53c2\u6570\u6307\u7684\u662f ",(0,s.jsx)(n.code,{children:"\u5355\u4e2a\u5b57\u7b26"})," \u7684\u5b57\u7b26\u4e32\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"-"})," \u4e00\u4e2a\u6a2a\u6746\u6307\u5b9a\u53c2\u6570\u53ca\u503c\uff0c\u5982\uff1a",(0,s.jsx)(n.code,{children:"-v"})," \u6216 ",(0,s.jsx)(n.code,{children:"-v 0.0.1"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"\u957f\u53c2\u6570"}),"\uff1a\u957f\u53c2\u6570\u6307\u7684\u662f\u4e00\u4e2a\u6216\u591a\u4e2a\u5355\u8bcd\u8fde\u63a5\u7684\u5b57\u7b26\u4e32\uff0c\u8be5\u53c2\u6570\u901a\u5e38\u548c ",(0,s.jsx)(n.code,{children:"\u77ed\u53c2\u6570"})," \u540c\u65f6\u5b58\u5728\uff0c\u901a\u5e38\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"--"})," \u6307\u5b9a\u53c2\u6570\u53ca\u503c\uff0c\u5982\uff1a",(0,s.jsx)(n.code,{children:"--version"})," \u6216 ",(0,s.jsx)(n.code,{children:"--version 0.0.1"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"\u64cd\u4f5c\u7b26"}),"\uff1a\u5b57\u7b26\u4e32\u4e2d\u4e0e\u53c2\u6570\u503c\u683c\u5f0f\u4e0d\u5339\u914d\u7684\u4efb\u4f55\u6587\u672c\u90fd\u88ab\u89c6\u4e3a\u64cd\u4f5c\u6570\uff0c\u4efb\u4f55\u51fa\u73b0\u5728\u53cc\u8fde\u5b57\u7b26 ",(0,s.jsx)(n.code,{children:"--"})," \u4e4b\u540e\u4e14\u672a\u5305\u542b\u5728\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7\u4e2d\u4e14\u4e24\u4fa7\u6709\u7a7a\u683c\u7684\u6587\u672c\u90fd\u88ab\u89c6\u4e3a\u64cd\u4f5c\u6570\uff0c\u65e0\u8bba\u5b83\u662f\u5426\u4e0e\u53c2\u6570\u503c\u683c\u5f0f\u5339\u914d\uff0c\u901a\u5e38\u7528\u4e8e\u5f52\u7c7b/\u5206\u7c7b\u4f5c\u7528\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"3721-\u77ed\u53c2\u6570\u4f8b\u5b50",children:"37.2.1 \u77ed\u53c2\u6570\u4f8b\u5b50"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"-a foo"})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u77ed\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"a"}),(0,s.jsx)(n.td,{children:"foo"})]})})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"-ab"})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u77ed\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"a"}),(0,s.jsx)(n.td,{})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"b"}),(0,s.jsx)(n.td,{})]})]})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"-abc bar"})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u77ed\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"a"}),(0,s.jsx)(n.td,{})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"b"}),(0,s.jsx)(n.td,{})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"c"}),(0,s.jsx)(n.td,{children:"bar"})]})]})]}),"\n",(0,s.jsx)(n.h3,{id:"3722-\u957f\u53c2\u6570\u4f8b\u5b50",children:"37.2.2 \u957f\u53c2\u6570\u4f8b\u5b50"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"--foo bar"})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u957f\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"foo"}),(0,s.jsx)(n.td,{children:"bar"})]})})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"--foo --bar"})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u957f\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"foo"}),(0,s.jsx)(n.td,{})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"bar"}),(0,s.jsx)(n.td,{})]})]})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"--foo bar --hello world"})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u957f\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"foo"}),(0,s.jsx)(n.td,{children:"bar"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"hello"}),(0,s.jsx)(n.td,{children:"world"})]})]})]}),"\n",(0,s.jsx)(n.h3,{id:"3723-\u6df7\u5408\u53c2\u6570\u4f8b\u5b50",children:"37.2.3 \u6df7\u5408\u53c2\u6570\u4f8b\u5b50"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:'-abc foo --hello world /new="slashes are ok too"'})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u77ed/\u957f\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"a"}),(0,s.jsx)(n.td,{})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"b"}),(0,s.jsx)(n.td,{})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"c"}),(0,s.jsx)(n.td,{children:"foo"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"hello"}),(0,s.jsx)(n.td,{children:"world"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"new"}),(0,s.jsx)(n.td,{children:"slashes are ok too"})]})]})]}),"\n",(0,s.jsx)(n.h3,{id:"3724-\u591a\u4e2a\u503c\u53c2\u6570",children:"37.2.4 \u591a\u4e2a\u503c\u53c2\u6570"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"--list 1 --list 2 --list 3"})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u957f\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"list"}),(0,s.jsx)(n.td,{children:"1,2,3"})]})})]}),"\n",(0,s.jsx)(n.h3,{id:"3725-\u64cd\u4f5c\u7b26",children:"37.2.5 \u64cd\u4f5c\u7b26"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:'-a foo bar "hello world" -b -- -explicit operand'})}),"\n"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u77ed\u53c2\u6570"}),(0,s.jsx)(n.th,{children:"\u53c2\u6570\u503c"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"a"}),(0,s.jsx)(n.td,{children:"foo"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"b"}),(0,s.jsx)(n.td,{})]})]})]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsx)(n.tr,{children:(0,s.jsx)(n.th,{children:"\u64cd\u4f5c\u7b26"})})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsx)(n.tr,{children:(0,s.jsx)(n.td,{children:"bar"})}),(0,s.jsx)(n.tr,{children:(0,s.jsx)(n.td,{children:'"hello world"'})}),(0,s.jsx)(n.tr,{children:(0,s.jsx)(n.td,{children:"-explicit"})}),(0,s.jsx)(n.tr,{children:(0,s.jsx)(n.td,{children:"operand"})})]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u5305\u547d\u4ee4\u8bed\u6cd5\u7684\u5b98\u65b9\u77e5\u8bc6\uff1a",(0,s.jsx)(n.a,{href:"https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html",children:"https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html"})]}),"\n",(0,s.jsx)(n.h2,{id:"373-\u7f16\u5199\u7b2c\u4e00\u4e2a\u5305",children:"37.3 \u7f16\u5199\u7b2c\u4e00\u4e2a\u5305"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"dotnet tools"})," \u5de5\u5177\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"\u63a7\u5236\u53f0"})," \u5e94\u7528\u7a0b\u5e8f\uff0c\u4e0d\u540c\u7684\u662f ",(0,s.jsx)(n.code,{children:".csproj"})," \u9879\u76ee\u6587\u4ef6\u9700\u8981\u6dfb\u52a0\u7279\u5b9a\u914d\u7f6e\u3002\u4e0b\u9762\u5c06\u7ed9\u5927\u5bb6\u7f16\u5199\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"HelloTools"})," \u5305\u7ba1\u7406\u5de5\u5177\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"3731-\u521b\u5efa-hellotools-\u63a7\u5236\u53f0\u5e94\u7528",children:["37.3.1 \u521b\u5efa ",(0,s.jsx)(n.code,{children:"HelloTools"})," \u63a7\u5236\u53f0\u5e94\u7528"]}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts1.png")}),"\n",(0,s.jsxs)(n.h3,{id:"3732-\u7f16\u8f91-hellotoolscsproj",children:["37.3.2 \u7f16\u8f91 ",(0,s.jsx)(n.code,{children:"HelloTools.csproj"})]}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u63a7\u5236\u53f0\u9879\u76ee\u6807\u8bb0\u6210 ",(0,s.jsx)(n.code,{children:"dotnet tools"})," \u9700\u8981\u914d\u7f6e\u4ee5\u4e0b\u8282\u70b9\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers {6-11}",children:'\r\n\r\n\t\r\n\t\tExe\r\n\t\tnet5.0\r\n \t0.0.1\r\n \t\u7b2c\u4e00\u4e2a dotnet tools \u5de5\u5177\r\n\t\thello-tools\r\n\t\ttrue\r\n\t\ttrue\r\n\t\t./nupkg\r\n\t\r\n\r\n\n'})}),"\n",(0,s.jsx)(n.h4,{id:"\u914d\u7f6e\u5173\u952e\u8282\u70b9\u8bf4\u660e",children:"\u914d\u7f6e\u5173\u952e\u8282\u70b9\u8bf4\u660e"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Version"}),"\uff1a\u5305\u5de5\u5177\u7248\u672c\u53f7"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Description"}),"\uff1a\u5305\u5de5\u5177\u4ecb\u7ecd"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"ToolCommandName"}),"\uff1a\u5305\u5de5\u5177\u5173\u952e\u5b57\uff0c\u5982 ",(0,s.jsx)(n.code,{children:"dotnet"}),"\u3001",(0,s.jsx)(n.code,{children:"npm"}),"\uff0c\u540e\u7eed\u4f7f\u7528\u90fd\u662f\u901a\u8fc7\u8be5\u5173\u952e\u5b57\u4f7f\u7528"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"PackAsTool"}),"\uff1a\u662f\u5426\u58f0\u660e\u4e3a\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u8bbe\u7f6e ",(0,s.jsx)(n.code,{children:"true"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"GeneratePackageOnBuild"}),"\uff1a\u662f\u5426\u7f16\u8bd1\u65f6\u81ea\u52a8\u751f\u6210 ",(0,s.jsx)(n.code,{children:".nupkg"})," \u5305\uff0c\u65b9\u4fbf\u540e\u7eed\u4e0a\u4f20\u5230 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5e73\u53f0"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"PackageOutputPath"}),"\uff1a\u914d\u7f6e ",(0,s.jsx)(n.code,{children:".nupkg"})," \u5305\u5b58\u50a8\u76ee\u5f55\uff0c\u63a8\u8350\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"./nupkg"})]}),"\n"]}),"\n",(0,s.jsxs)(n.h3,{id:"3733-\u5b89\u88c5-furiontoolscommandline-\u5305",children:["37.3.3 \u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Furion.Tools.CommandLine"})," \u5305"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u65b9\u4fbf\u7ba1\u7406\u5de5\u5177\u5305\u5f00\u53d1\uff0c",(0,s.jsx)(n.code,{children:"Furion"})," \u5b98\u65b9\u7279\u610f\u5f00\u53d1\u4e86 ",(0,s.jsx)(n.code,{children:"Furion.Tools.CommandLine"})," \u5305\uff0c\u5e2e\u52a9\u5927\u5bb6\u5feb\u901f\u5f00\u53d1\u7ba1\u7406\u5de5\u5177\u5305\u3002"]}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts2.png")}),"\n",(0,s.jsx)(n.h3,{id:"3734-\u7f16\u5199\u903b\u8f91\u4ee3\u7801",children:"37.3.4 \u7f16\u5199\u903b\u8f91\u4ee3\u7801"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u5148\u5b9a\u4e49\u51e0\u4e2a\u9700\u6c42\uff0c\u7136\u540e\u7f16\u5199\u903b\u8f91\u4ee3\u7801\uff1a"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u4e00\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"hello-tools"})," \u6253\u5370\u4ecb\u7ecd\u4fe1\u606f"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u4e8c\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"-n"})," \u6216 ",(0,s.jsx)(n.code,{children:"--name"})," \u8f93\u51fa ",(0,s.jsx)(n.code,{children:"Hello \u540d\u5b57"})]}),"\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u4e09\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"-v"})," \u6216 ",(0,s.jsx)(n.code,{children:"--version"})," \u8f93\u51fa\u5f53\u524d\u7248\u672c"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u56db\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"-h"})," \u6216 ",(0,s.jsx)(n.code,{children:"--help"})," \u8f93\u51fa\u5e2e\u52a9\u6587\u6863"]}),"\n"]}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:["\u751f\u6210\u63a7\u5236\u53f0 ",(0,s.jsx)(n.code,{children:"LOGO"})]}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u4e0d\u652f\u6301\u4e2d\u6587\uff1a",(0,s.jsx)(n.a,{href:"http://patorjk.com/software/taag/#p=display&f=Big&t=Furion%20Tools",children:"http://patorjk.com/software/taag/#p=display&f=Big&t=Furion%20Tools"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u652f\u6301\u6240\u6709\u5b57\u7b26\uff1a",(0,s.jsx)(n.a,{href:"https://www.qqxiuzi.cn/zh/dianzhenzi-zifu/",children:"https://www.qqxiuzi.cn/zh/dianzhenzi-zifu/"})]}),"\n"]})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,10,15-18,26-29,37-40,45}",children:'using Furion.Tools.CommandLine;\r\nusing System;\r\nusing System.Collections.Generic;\r\n\r\nnamespace HelloTools\r\n{\r\n class Program\r\n {\r\n // \u901a\u8fc7 Cli.Inject() \u5b8c\u6210\u51c6\u5907\u5de5\u4f5c\r\n static void Main(string[] args) => Cli.Inject();\r\n\r\n /// \r\n /// \u8f93\u51fa Hello \u540d\u5b57\r\n /// \r\n [Argument(\'n\', "name", "\u60a8\u7684\u540d\u5b57")]\r\n static string Name { get; set; }\r\n // \u5b9a\u4e49\u53c2\u6570\u5904\u7406\u7a0b\u5e8f\uff0c\u5fc5\u987b [\u5c5e\u6027\u540d]+Handler\r\n static void NameHandler(ArgumentMetadata argument)\r\n {\r\n Console.WriteLine($"Hello {Name}");\r\n }\r\n\r\n /// \r\n /// \u67e5\u770b\u7248\u672c\r\n /// \r\n [Argument(\'v\', "version", "\u5de5\u5177\u7248\u672c\u53f7")]\r\n static bool Version { get; set; }\r\n // \u5b9a\u4e49\u53c2\u6570\u5904\u7406\u7a0b\u5e8f\uff0c\u5fc5\u987b [\u5c5e\u6027\u540d]+Handler\r\n static void VersionHandler(ArgumentMetadata argument)\r\n {\r\n Console.WriteLine(Cli.GetVersion());\r\n }\r\n\r\n /// \r\n /// \u67e5\u770b\u5e2e\u52a9\u6587\u6863\r\n /// \r\n [Argument(\'h\', "help", "\u67e5\u770b\u5e2e\u52a9\u6587\u6863")]\r\n static bool Help { get; set; }\r\n // \u5b9a\u4e49\u53c2\u6570\u5904\u7406\u7a0b\u5e8f\uff0c\u5fc5\u987b [\u5c5e\u6027\u540d]+Handler\r\n static void HelpHandler(ArgumentMetadata argument)\r\n {\r\n Cli.GetHelpText("hello-tools");\r\n }\r\n\r\n // \u6240\u6709\u672a\u5339\u914d\u7684\u53c2\u6570/\u64cd\u4f5c\u7b26\u5904\u7406\u7a0b\u5e8f\uff0c\u56fa\u5b9a NoMatchesHandler \u65b9\u6cd5\u540d\r\n static void NoMatchesHandler(bool isEmpty, string[] operands, Dictionary noMatches)\r\n {\r\n if (isEmpty)\r\n {\r\n Console.WriteLine(@"\r\n _ _ _ _ _______ _\r\n | | | | | | | |__ __| | |\r\n | |__| | ___| | | ___ | | ___ ___ | |___\r\n | __ |/ _ \\ | |/ _ \\ | |/ _ \\ / _ \\| / __|\r\n | | | | __/ | | (_) | | | (_) | (_) | \\__ \\\r\n |_| |_|\\___|_|_|\\___/ |_|\\___/ \\___/|_|___/\r\n\r\n\r\n");\r\n Console.WriteLine($"\u6b22\u8fce\u4f7f\u7528{Cli.GetDescription()}");\r\n }\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{title:"\u4ee3\u7801\u8bf4\u660e",type:"tip",children:(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u5de5\u5177\u5305\u63d0\u4f9b\u4e86\u975e\u5e38\u65b9\u4fbf\u7684 ",(0,s.jsx)(n.code,{children:"Cli.Inject()"})," \u65b9\u6cd5\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4e00\u6b21\u6027\u5b8c\u6210\u6240\u6709\u521d\u59cb\u5316\u5de5\u4f5c\uff0c\u53ea\u9700\u8981\u5728 ",(0,s.jsx)(n.code,{children:"Main"})," \u65b9\u6cd5\u8c03\u7528\u5373\u53ef"]}),"\n",(0,s.jsxs)(n.li,{children:["\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"[Argument(\u77ed\u53c2\u6570\uff0c\u957f\u53c2\u6570\uff0c\u63d0\u793a\u6587\u6863)]"})," \u5b9a\u4e49\u6bcf\u4e00\u4e2a\u53c2\u6570\u5c5e\u6027\uff0c\u53c2\u6570\u5fc5\u987b\u662f ",(0,s.jsx)(n.code,{children:"static"})," \u9759\u6001"]}),"\n",(0,s.jsxs)(n.li,{children:["\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"[\u5c5e\u6027\u540d]Handler"})," \u5b9a\u4e49\u6bcf\u4e2a\u53c2\u6570\u5339\u914d\u540e\u7684\u5904\u7406\u7a0b\u5e8f\uff0c\u5982\uff1a",(0,s.jsx)(n.code,{children:"VersionHandler"}),"\uff0c\u683c\u5f0f\u4e3a\uff1a",(0,s.jsx)(n.code,{children:"static void \u5c5e\u6027\u540dHandler(ArgumentMetadata argument)"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u901a\u8fc7\u56fa\u5b9a\u65b9\u6cd5\u540d ",(0,s.jsx)(n.code,{children:"NoMatchesHandler"})," \u5b9a\u4e49\u672a\u5339\u914d\u7684\u53c2\u6570\u53ca\u64cd\u4f5c\u7b26\uff0c\u8be5\u65b9\u6cd5\u6709\u4e09\u4e2a\u53c2\u6570\uff1a","\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"isEmpty"}),"\uff1a\u5224\u65ad\u662f\u5426\u6ca1\u6709\u4f20\u9012\u4efb\u4f55\u53c2\u6570\uff0c\u901a\u5e38\u7528\u4e8e\u8f93\u51fa\u4ecb\u7ecd"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"operands"}),"\uff1a\u83b7\u53d6\u6240\u6709\u64cd\u4f5c\u7b26\u5217\u8868"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"noMatches"}),"\uff1a\u83b7\u53d6\u6240\u6709\u672a\u5339\u914d\u7684\u53c2\u6570\u5b57\u5178"]}),"\n"]}),"\n"]}),"\n"]})}),"\n",(0,s.jsx)(n.h3,{id:"3735-\u5982\u4f55\u8c03\u8bd5\u5305\u5de5\u5177-",children:"37.3.5 \u5982\u4f55\u8c03\u8bd5\u5305\u5de5\u5177 \ud83d\udc4f"}),"\n",(0,s.jsxs)(n.p,{children:["\u5305\u7ba1\u7406\u5de5\u5177\u8c03\u8bd5\u6709\u522b\u4e8e\u666e\u901a\u7684\u63a7\u5236\u53f0\uff0c\u4e3b\u8981\u533a\u522b\u662f\u6d4b\u8bd5\u5404\u4e2a\u53c2\u6570\u7684\u4f7f\u7528\uff0c\u4e5f\u5c31\u662f\u5982\u4f55\u4f20\u9012 ",(0,s.jsx)(n.code,{children:"Main"})," \u65b9\u6cd5\u7684 ",(0,s.jsx)(n.code,{children:"args"})," \u53c2\u6570\u3002\u53ea\u9700\u8981\u4ee5\u4e0b\u4e24\u4e2a\u6b65\u9aa4\u5373\u53ef\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5728\u9879\u76ee\u6839\u76ee\u5f55\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"Properties"})," \u76ee\u5f55"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"Properties"})," \u76ee\u5f55\u4e2d\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"launchSettings.json"})," \u6587\u4ef6\uff0c\u5e76\u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers {3,5}",children:'{\r\n "profiles": {\r\n "\u9879\u76ee\u540d\u79f0": {\r\n "commandName": "Project",\r\n "commandLineArgs": "\u4f60\u7684\u547d\u4ee4"\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"\u9879\u76ee\u540d\u79f0"}),"\uff1a\u5199\u4f60\u7684\u9879\u76ee\u5b9e\u9645\u540d\u79f0\uff0c\u5982\uff1a",(0,s.jsx)(n.code,{children:"HelloTools"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"commandName"}),"\uff1a\u56fa\u5b9a\u4e3a ",(0,s.jsx)(n.code,{children:"Project"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"commandLineArgs"}),"\uff1a\u7f16\u5199\u6d4b\u8bd5\u547d\u4ee4\uff0c\u53ea\u9700\u8981\u5199\u53c2\u6570/\u64cd\u4f5c\u7b26\u90e8\u5206\u5373\u53ef\uff0c\u5982\uff1a",(0,s.jsx)(n.code,{children:"-v"}),"\uff0c",(0,s.jsx)(n.code,{children:"-v -h --Name Furion"})]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\uff0c\u6211\u4eec\u9700\u8981\u6d4b\u8bd5 ",(0,s.jsx)(n.code,{children:"HelloTools"})," \u7684 ",(0,s.jsx)(n.code,{children:"-n"})," \u53c2\u6570"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers {3,5}",children:'{\r\n "profiles": {\r\n "HelloTools": {\r\n "commandName": "Project",\r\n "commandLineArgs": "-n Furion"\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts3.png")}),"\n",(0,s.jsxs)(n.p,{children:["\u70b9\u51fb ",(0,s.jsx)(n.code,{children:"\u8fd0\u884c/\u8c03\u8bd5/F5"})," \u542f\u52a8\u8c03\u8bd5"]}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts4.png")}),"\n",(0,s.jsx)(n.h3,{id:"3736-\u6d4b\u8bd5\u5404\u4e2a\u53c2\u6570\u60c5\u51b5",children:"37.3.6 \u6d4b\u8bd5\u5404\u4e2a\u53c2\u6570\u60c5\u51b5"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u4e00\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"hello-tools"})," \u6253\u5370\u4ecb\u7ecd\u4fe1\u606f"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers {5}",children:'{\r\n "profiles": {\r\n "HelloTools": {\r\n "commandName": "Project",\r\n "commandLineArgs": ""\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts5.png")}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u4e8c\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"-n"})," \u6216 ",(0,s.jsx)(n.code,{children:"--name"})," \u8f93\u51fa ",(0,s.jsx)(n.code,{children:"Hello \u540d\u5b57"})]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers {5}",children:'{\r\n "profiles": {\r\n "HelloTools": {\r\n "commandName": "Project",\r\n "commandLineArgs": "-n Furion"\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts6.png")}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u4e09\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"-v"})," \u6216 ",(0,s.jsx)(n.code,{children:"--version"})," \u8f93\u51fa\u5f53\u524d\u7248\u672c"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers {5}",children:'{\r\n "profiles": {\r\n "HelloTools": {\r\n "commandName": "Project",\r\n "commandLineArgs": "--version"\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts7.png")}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u9700\u6c42\u56db\uff1a\u8f93\u5165 ",(0,s.jsx)(n.code,{children:"-h"})," \u6216 ",(0,s.jsx)(n.code,{children:"--help"})," \u8f93\u51fa\u5e2e\u52a9\u6587\u6863"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers {5}",children:'{\r\n "profiles": {\r\n "HelloTools": {\r\n "commandName": "Project",\r\n "commandLineArgs": "-h"\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts8.png")}),"\n",(0,s.jsx)(n.h2,{id:"374-\u6253\u5305\u672c\u673a\u6d4b\u8bd5",children:"37.4 \u6253\u5305\uff08\u672c\u673a\uff09\u6d4b\u8bd5"}),"\n",(0,s.jsxs)(n.p,{children:["\u521a\u521a\u6211\u4eec\u5df2\u7ecf\u5b66\u4f1a\u8c03\u8bd5\u5305\u5de5\u5177\u4e86\uff0c\u4f46\u662f\u8fd8\u672a\u505a\u5230\u7c7b\u4f3c ",(0,s.jsx)(n.code,{children:"npm"})," \u5305\u4e00\u6837\uff0c\u5728 ",(0,s.jsx)(n.code,{children:"cmd/powershell"})," \u4e2d\u5b89\u88c5\u4e4b\u540e\u53ef\u5728\u547d\u4ee4\u884c\u5168\u5c40\u6d4b\u8bd5\uff0c\u4e0b\u9762\u5c06\u6559\u5927\u5bb6\u5982\u4f55\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"\u5168\u5c40\u5b89\u88c5"})," \u548c ",(0,s.jsx)(n.code,{children:"\u672c\u5730\u5b89\u88c5"}),"\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"3741-\u5168\u5c40\u6253\u5305\u5b89\u88c5",children:"37.4.1 \u5168\u5c40\u6253\u5305\u5b89\u88c5"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u5168\u5c40\u6253\u5305\u5b89\u88c5\u5c31\u662f\u914d\u7f6e\u5728\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u5728\u4efb\u4f55\u5730\u65b9\u90fd\u53ef\u4ee5\u4f7f\u7528\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"HelloTools"})," \u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u6253\u5f00 ",(0,s.jsx)(n.code,{children:"cmd/powershell"}),"\uff08",(0,s.jsx)(n.strong,{children:"\u5c3d\u91cf\u4f7f\u7528\u7ba1\u7406\u5458\u5de5\u5177"}),"\uff09\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a"]}),"\n",(0,s.jsx)(n.h4,{id:"-\u5b89\u88c5\u5168\u5c40\u5305",children:"\u2714 \u5b89\u88c5\u5168\u5c40\u5305"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet tool install --global --add-source ./nupkg HelloTools\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5176\u4e2d ",(0,s.jsx)(n.code,{children:"HelloTools"})," \u5c31\u662f ",(0,s.jsx)(n.code,{children:"\u9879\u76ee\u540d\u79f0"}),"\u3002"]}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts9.png")}),"\n",(0,s.jsxs)(n.p,{children:["\u4e4b\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e4b\u524d ",(0,s.jsx)(n.code,{children:"HelloTools.csproj"})," \u4e2d\u914d\u7f6e\u7684 ",(0,s.jsx)(n.code,{children:"hello-tools"})," \u4f7f\u7528\u4e86\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"-\u6d4b\u8bd5\u5168\u5c40\u5305",children:"\u2714 \u6d4b\u8bd5\u5168\u5c40\u5305"}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts10.png")}),"\n",(0,s.jsx)(n.h4,{id:"-\u66f4\u65b0\u5168\u5c40\u5305",children:"\u2714 \u66f4\u65b0\u5168\u5c40\u5305"}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u6e90\u7801\u53d1\u751f\u6539\u53d8\uff0c\u53ea\u9700\u8981\u7f16\u8bd1\u9879\u76ee\u540e\u91cd\u65b0\u66f4\u65b0\u5305\u5de5\u5177\u5373\u53ef\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet tool update --global --add-source ./nupkg HelloTools\n"})}),"\n",(0,s.jsx)(n.h4,{id:"-\u5378\u8f7d\u5168\u5c40\u5305",children:"\u2714 \u5378\u8f7d\u5168\u5c40\u5305"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet tool uninstall --global HelloTools\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u60f3\u4e86\u89e3\u66f4\u591a\u5168\u5c40\u6253\u5305\u5b89\u88c5\u77e5\u8bc6\u67e5\u9605\u5b98\u65b9\u6587\u6863\u5373\u53ef\uff1a",(0,s.jsx)(n.a,{href:"https://docs.microsoft.com/zh-cn/dotnet/core/tools/global-tools-how-to-use",children:"https://docs.microsoft.com/zh-cn/dotnet/core/tools/global-tools-how-to-use"})]}),"\n",(0,s.jsx)(n.h3,{id:"3742-\u672c\u5730\u6253\u5305\u5b89\u88c5",children:"37.4.2 \u672c\u5730\u6253\u5305\u5b89\u88c5"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u672c\u5730\u6253\u5305\u5b89\u88c5\u5c31\u662f\u53ea\u6709\u5728\u9879\u76ee\u6240\u5728\u76ee\u5f55\u53ca\u5b50\u5b59\u76ee\u5f55\u65b9\u53ef\u4f7f\u7528\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"HelloTools"})," \u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u6253\u5f00 ",(0,s.jsx)(n.code,{children:"cmd/powershell"})," \u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a"]}),"\n",(0,s.jsx)(n.h4,{id:"-\u521b\u5efa\u672c\u5730\u6e05\u5355\u6587\u4ef6",children:"\u2714 \u521b\u5efa\u672c\u5730\u6e05\u5355\u6587\u4ef6"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet new tool-manifest\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6267\u884c\u8be5\u547d\u4ee4\u540e\u4f1a\u81ea\u52a8\u521b\u5efa ",(0,s.jsx)(n.code,{children:".config"})," \u6587\u4ef6\u5939\u5e76\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"dotnet-tools.json"})," \u6587\u4ef6\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers",children:'{\r\n "version": 1,\r\n "isRoot": true,\r\n "tools": {}\r\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{title:"\u6ce8\u610f\u4e8b\u9879",type:"warning",children:(0,s.jsx)(n.p,{children:"\u901a\u5e38\u8be5\u6587\u4ef6\u5185\u5bb9\u4e0d\u9700\u8981\u624b\u52a8\u66f4\u6539\u3002"})}),"\n",(0,s.jsx)(n.h4,{id:"-\u5b89\u88c5\u672c\u5730\u5305",children:"\u2714 \u5b89\u88c5\u672c\u5730\u5305"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet tool install --add-source ./nupkg HelloTools\n"})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts11.png")}),"\n",(0,s.jsx)(n.h4,{id:"-\u6d4b\u8bd5\u672c\u5730\u5305",children:"\u2714 \u6d4b\u8bd5\u672c\u5730\u5305"}),"\n",(0,s.jsxs)(n.p,{children:["\u672c\u5730\u5305\u6d4b\u8bd5\u548c\u5168\u5c40\u5305\u4e0d\u4e00\u6837\u7684\u662f\u672c\u5730\u5305\u662f\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"dotnet \u5173\u952e\u5b57 \u53c2\u6570"})," \u6d4b\u8bd5\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet hello-tools -n Furion\n"})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts12.png")}),"\n",(0,s.jsx)(n.h4,{id:"-\u66f4\u65b0\u672c\u5730\u5305",children:"\u2714 \u66f4\u65b0\u672c\u5730\u5305"}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u6e90\u7801\u53d1\u751f\u6539\u53d8\uff0c\u53ea\u9700\u8981\u7f16\u8bd1\u9879\u76ee\u540e\u91cd\u65b0\u66f4\u65b0\u5305\u5de5\u5177\u5373\u53ef\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet tool update --add-source ./nupkg HelloTools\n"})}),"\n",(0,s.jsx)(n.h4,{id:"-\u5378\u8f7d\u672c\u5730\u5305",children:"\u2714 \u5378\u8f7d\u672c\u5730\u5305"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet tool uninstall HelloTools\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u60f3\u4e86\u89e3\u66f4\u591a\u672c\u5730\u6253\u5305\u5b89\u88c5\u77e5\u8bc6\u67e5\u9605\u5b98\u65b9\u6587\u6863\u5373\u53ef\uff1a",(0,s.jsx)(n.a,{href:"https://docs.microsoft.com/zh-cn/dotnet/core/tools/local-tools-how-to-use",children:"https://docs.microsoft.com/zh-cn/dotnet/core/tools/local-tools-how-to-use"})]}),"\n",(0,s.jsxs)(n.h2,{id:"375-\u53d1\u5e03\u5230-nuget-\u5e73\u53f0-",children:["37.5 \u53d1\u5e03\u5230 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5e73\u53f0 \ud83d\udc4f"]}),"\n",(0,s.jsxs)(n.p,{children:["\u53d1\u5e03\u5230 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5e73\u53f0\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4e24\u4e2a\u6b65\u9aa4\u5373\u53ef\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5207\u6362\u9879\u76ee ",(0,s.jsx)(n.code,{children:"Debug"})," \u6a21\u5f0f\u5230 ",(0,s.jsx)(n.code,{children:"Release"})," \u5e76\u91cd\u65b0\u7f16\u8bd1\u9879\u76ee"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5e73\u53f0\u4e0a\u4f20 ",(0,s.jsx)(n.code,{children:"nupkg"})," \u6587\u4ef6\u5939\u5bf9\u5e94 ",(0,s.jsx)(n.code,{children:"\u9879\u76ee\u540d\u79f0.\u7248\u672c\u53f7.nupkg"})," \u6587\u4ef6\u5373\u53ef\uff1a",(0,s.jsx)(n.a,{href:"https://www.nuget.org/packages/manage/upload",children:"https://www.nuget.org/packages/manage/upload"})]}),"\n"]}),"\n",(0,s.jsxs)(n.admonition,{title:"\u4e0a\u4f20 NuGet \u5e73\u53f0\u8865\u9f50\u4fe1\u606f",type:"tip",children:[(0,s.jsxs)(n.p,{children:["\u5efa\u8bae\u4e0a\u4f20\u5230 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5e73\u53f0\u7f16\u8f91 ",(0,s.jsx)(n.code,{children:".csproj"})," \u6587\u4ef6\u8865\u9f50\u4ee5\u4e0b\u4fe1\u606f\uff1a"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {13-21}",children:'\r\n\r\n\t\r\n\t\tExe\r\n\t\tnet5.0\r\n\t\t0.0.1\r\n\t\t\u7b2c\u4e00\u4e2a dotnet tools \u5de5\u5177\r\n\t\thello-tools\r\n\t\ttrue\r\n\t\ttrue\r\n\t\t./nupkg\r\n\r\n\t\t\u767e\u5c0f\u50e7\r\n\t\t\u767e\u7b7e\u79d1\u6280\uff08\u5e7f\u4e1c\uff09\u6709\u9650\u516c\u53f8\r\n\t\tFurion\r\n\t\t\xa9 2020-present \u767e\u5c0f\u50e7, \u767e\u7b7e\u79d1\u6280\uff08\u5e7f\u4e1c\uff09\u6709\u9650\u516c\u53f8\r\n\t\thttps://gitee.com/dotnetchina/Furion\r\n\t\tGitee\r\n\t\ttrue\r\n\t\tMIT\r\n\t\thttp://furion.baiqian.ltd\r\n\t\r\n\r\n\t\r\n\t\t\r\n\t\r\n\r\n\n'})})]}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts13.png")}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ts14.png")}),"\n",(0,s.jsxs)(n.p,{children:["\u53d1\u5e03\u5230 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5e73\u53f0\u540e\uff0c\u522b\u4eba\u5c31\u53ef\u4ee5\u901a\u8fc7\uff1a"]}),"\n",(0,s.jsx)(n.h4,{id:"-\u5b89\u88c5-nuget-\u5305\u5230\u672c\u5730",children:"\u2714 \u5b89\u88c5 NuGet \u5305\u5230\u672c\u5730"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet tool install --global \u9879\u76ee\u540d --version \u7248\u672c\u53f7\n"})}),"\n",(0,s.jsxs)(n.h2,{id:"376-cli-\u9759\u6001\u7c7b\u8bf4\u660e",children:["37.6 ",(0,s.jsx)(n.code,{children:"Cli"})," \u9759\u6001\u7c7b\u8bf4\u660e"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u7b80\u5316\u5305\u5de5\u5177\u7684\u5f00\u53d1\uff0c",(0,s.jsx)(n.code,{children:"Furion.Tools.CommandLine"})," \u7684 ",(0,s.jsx)(n.code,{children:"Cli"})," \u9759\u6001\u7c7b\u63d0\u4f9b\u4e86\u5f88\u591a\u65b9\u4fbf\u7684\u9759\u6001\u65b9\u6cd5\uff1a"]}),"\n",(0,s.jsx)(n.h3,{id:"3761-\u6d88\u606f\u7c7b",children:"37.6.1 \u6d88\u606f\u7c7b"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'// \u8f93\u51fa\u7a7a\u884c\r\nCli.EmptyLine();\r\n\r\n// \u8f93\u51fa\u4e00\u884c\r\nCli.WriteLine("\u6d88\u606f");\r\nCli.WriteLine("\u6d88\u606f", ConsoleColor.Blue); // \u5b57\u4f53\u989c\u8272\r\nCli.WriteLine("\u6d88\u606f", ConsoleColor.Blue, ConsoleColor.White); // \u80cc\u666f\u989c\u8272\r\nCli.WriteLine("\u6d88\u606f", ConsoleColor.Blue, ConsoleColor.White, fillLine: true); // \u586b\u5145\u6574\u884c\r\n\r\n// \u8f93\u51fa\uff08\u4e0d\u6362\u884c\uff09\r\nCli.Write("\u6d88\u606f");\r\nCli.Write("\u6d88\u606f", ConsoleColor.Blue); // \u5b57\u4f53\u989c\u8272\r\nCli.Write("\u6d88\u606f", ConsoleColor.Blue, ConsoleColor.White); // \u80cc\u666f\u989c\u8272\r\nCli.Write("\u6d88\u606f", ConsoleColor.Blue, ConsoleColor.White, fillLine: true); // \u586b\u5145\u6574\u884c\r\n\r\n// \u8f93\u51fa\u63d0\u793a\u6d88\u606f\r\nCli.Success("\u6210\u529f");\r\nCli.Warn("\u8b66\u544a");\r\nCli.Error("\u9519\u8bef");\r\nCli.Tip("\u63d0\u793a");\r\n\r\n// \u6536\u96c6\u7528\u6237\u8f93\u5165\uff08\u652f\u6301\u591a\u884c\uff09\r\nvar inputs = Cli.ReadInput(); // \u8f93\u5165 exit \u9000\u51fa\u8f93\u5165\r\n\r\n// \u9009\u62e9\u6d88\u606f\r\nvar selectId = Cli.ReadOptions("\u8bf7\u9009\u62e9\u559c\u6b22\u7684\u6c34\u679c\uff1a", new []{ "\u897f\u74dc", "\u82f9\u679c", "\u51e4\u68a8"}); // selectId \u4ece 1 \u5f00\u59cb\n'})}),"\n",(0,s.jsx)(n.h3,{id:"3762-\u5de5\u5177\u7c7b",children:"37.6.2 \u5de5\u5177\u7c7b"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'// \u5b8c\u6210\u53c2\u6570\u586b\u5145\u5c5e\u6027\u521d\u59cb\u5316\u64cd\u4f5c\r\nCli.Inject();\r\n\r\n// \u83b7\u53d6\u53c2\u6570\u6240\u6709\u4fe1\u606f\r\nvar arguments = Cli.ArgumentMetadatas;\r\n\r\n// \u624b\u52a8\u68c0\u67e5\u53c2\u6570\u662f\u5426\u5339\u914d\r\nCli.Check(nameof(\u5c5e\u6027\u540d), argument => {\r\n // \u5982\u679c\u7528\u6237\u8f93\u5165\u8be5\u53c2\u6570\r\n if(argument?.IsTransmission == true){\r\n Cli.WriteLine(argument.Value);\r\n }\r\n else {\r\n Cli.Error("\u7528\u6237\u6ca1\u6709\u8f93\u5165");\r\n }\r\n});\r\n\r\n// \u53ea\u6709\u53c2\u6570\u5339\u914d\u624d\u8fdb\u5165\r\nCli.CheckMatch(nameof(\u5c5e\u6027\u540d), argument => {\r\n Cli.WriteLine(argument.Value);\r\n})\r\n\r\n// \u65e0\u5c5e\u6027\u68c0\u67e5\r\nCli.Check(new[] {"v", "version"}, (isMatch, value) => {\r\n // \u5982\u679c\u7528\u6237\u8f93\u5165\u8be5\u53c2\u6570\r\n if(isMatch){\r\n Cli.WriteLine(value);\r\n }\r\n else {\r\n Cli.Error("\u7528\u6237\u6ca1\u6709\u8f93\u5165");\r\n }\r\n});\r\n\r\n// \u65e0\u5c5e\u6027\u5339\u914d\r\nCli.CheckMatch(new[] {"v", "version"}, value => {\r\n Cli.WriteLine(value);\r\n});\r\n\r\n// \u6240\u6709\u672a\u5339\u914d\u7684\u53c2\u6570\u3001\u64cd\u4f5c\u7b26\r\nCli.CheckNoMatches((isEmpty, operands, noMatches) => {\r\n if (isEmpty) Cli.WriteLine($"\u6b22\u8fce\u4f7f\u7528 {Cli.GetDescription()}");\r\n if (operands.Length > 0) Cli.Error($"\u672a\u627e\u5230\u8be5\u64cd\u4f5c\u7b26\uff1a{string.Join(",", operands)}");\r\n if (noMatches.Count > 0) Cli.Error($"\u672a\u627e\u5230\u8be5\u53c2\u6570\uff1a{string.Join(",", noMatches.Keys)}");\r\n});\r\n\r\n// \u89e3\u6790 Main \u65b9\u6cd5\u53c2\u6570\u4fe1\u606f\r\nvar argumentModel = Cli.Parse();\r\n\r\n// \u624b\u52a8\u89e3\u6790\u547d\u4ee4\u5b57\u7b26\u4e32\r\nvar argumentModel = Cli.Parse("-abc foo --hello world");\r\n\r\n// \u7ec8\u6b62\u8f93\u51fa/\u7ed3\u675f\u8f93\u51fa\r\nCli.Exit();\n'})}),"\n",(0,s.jsx)(n.h3,{id:"3762-\u4fe1\u606f\u7c7b",children:"37.6.2 \u4fe1\u606f\u7c7b"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// \u83b7\u53d6\u5f53\u524d\u5de5\u5177\u5305\u7248\u672c\u53f7\r\nvar version = Cli.GetVersion();\r\n\r\n// \u83b7\u53d6\u5f53\u524d\u5de5\u5177\u5305\u63cf\u8ff0\r\nvar description = Cli.GetDescription();\n"})}),"\n",(0,s.jsx)(n.h3,{id:"3763-\u5176\u4ed6\u7c7b",children:"37.6.3 \u5176\u4ed6\u7c7b"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"Environment"})," \u83b7\u53d6\u5f53\u524d\u73af\u5883\u66f4\u591a\u4fe1\u606f\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// \u5f53\u524d\u6267\u884c\u547d\u4ee4\u76ee\u5f55\r\nvar currentDirectory = Environment.CurrentDirectory;\r\n\r\n// \u83b7\u53d6\u673a\u5668\u540d\u79f0\r\nvar machineName = Environment.MachineName;\r\n\r\n// \u7b49\u7b49\u3002\u3002\u3002\u3002\u3002\n"})}),"\n",(0,s.jsxs)(n.h2,{id:"377-\u96c6\u6210-spectreconsole",children:["37.7 \u96c6\u6210 ",(0,s.jsx)(n.code,{children:"Spectre.Console"})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Spectre.Console"})," \u662f ",(0,s.jsx)(n.code,{children:".NET/C#"})," \u5e73\u53f0\u975e\u5e38\u4f18\u79c0\u7684\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f ",(0,s.jsx)(n.code,{children:"UI"})," \u6846\u67b6\u5e93\uff0c\u63d0\u4f9b\u975e\u5e38\u591a\u5f00\u7bb1\u53ef\u7528\u4e14\u975e\u5e38\u597d\u770b\u7684 ",(0,s.jsx)(n.code,{children:"UI"})," \u7ec4\u4ef6\u3002\u5b98\u7f51\u5730\u5740\uff1a",(0,s.jsx)(n.a,{href:"https://spectreconsole.net/",children:"https://spectreconsole.net/"})]}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Spectre.Console.Cli"})," \u62d3\u5c55\u5305\u5373\u53ef\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet add package Spectre.Console.Cli\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e4b\u540e\u5728\u63a7\u5236\u53f0\u8f93\u51fa\u5e26\u4e0b\u5212\u7ebf\u7ea2\u8272\u7684 ",(0,s.jsx)(n.code,{children:"Hello"})," \u548c ",(0,s.jsx)(n.code,{children:"world!"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,7}",children:'using Spectre.Console;\r\n\r\npublic static class Program\r\n{\r\n public static void Main(string[] args)\r\n {\r\n AnsiConsole.Markup("[underline red]Hello[/] World!");\r\n }\r\n}\n'})}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:[(0,s.jsx)(n.code,{children:"Spectre.Console"})," \u548c ",(0,s.jsx)(n.code,{children:"Spectre.Console.Cli"})," \u533a\u522b"]}),(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Spectre.Console"})," \u662f\u4e0d\u5305\u542b ",(0,s.jsx)(n.code,{children:"args"})," \u547d\u4ee4\u884c\u53c2\u6570\u89e3\u6790\u7684\uff0c\u4f46\u4f5c\u4e3a\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"tools"})," \u5de5\u5177\u5bf9\u4e8e\u89e3\u6790 ",(0,s.jsx)(n.code,{children:"args"})," \u53c2\u6570\u663e\u5f97\u975e\u5e38\u91cd\u8981\uff0c\u6240\u4ee5\u63a8\u8350\u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Spectre.Console.Cli"}),"\u3002"]}),(0,s.jsxs)(n.p,{children:["\u5982\u679c\u5b89\u88c5\u4e86 ",(0,s.jsx)(n.code,{children:"Spectre.Console.Cli"})," \u4e4b\u540e\u5219\u65e0\u9700\u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Furion.Tools.CommandLine"})," \u62d3\u5c55\u5305\u4e86\u3002"]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0b\u9762\u662f ",(0,s.jsx)(n.code,{children:"Spectre.Console"})," \u7684 ",(0,s.jsx)(n.code,{children:"UI"})," \u7ec4\u4ef6 \u9884\u89c8\u56fe\uff1a"]}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/cli1.png")}),"\n",(0,s.jsxs)(n.h2,{id:"378-\u96c6\u6210-cliwrap",children:["37.8 \u96c6\u6210 ",(0,s.jsx)(n.code,{children:"CliWrap"})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"CliWrap"})," \u540c\u6837\u4e5f\u662f ",(0,s.jsx)(n.code,{children:".NET/C#"})," \u5e73\u53f0\u975e\u5e38\u4f18\u79c0\u7684\u6267\u884c\u672c\u5730\u547d\u4ee4\u7684\u5e93\uff0c\u53ef\u901a\u8fc7\u8be5\u5e93\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"CMD/Powershell"})," \u547d\u4ee4\u6267\u884c\uff0c\u975e\u5e38\u5f3a\u5927\u3002\u4ed3\u5e93\u5730\u5740\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/Tyrrrz/CliWrap",children:"https://github.com/Tyrrrz/CliWrap"})]}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"NuGet"})," \u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Spectre.Console.Cli"})," \u62d3\u5c55\u5305\u5373\u53ef\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet add package CliWrap\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6bd4\u5982\u6267\u884c ",(0,s.jsx)(n.code,{children:'git commit -m "my commit"'})," \u64cd\u4f5c\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'// \u5b57\u7b26\u4e32\u53c2\u6570\u65b9\u5f0f\r\nvar cmd = Cli.Wrap("git")\r\n .WithArguments("commit -m \\"my commit\\"");\r\n\r\n// \u6570\u7ec4\u53c2\u6570\u65b9\u5f0f\r\nvar cmd = Cli.Wrap("git")\r\n .WithArguments(new[] {"commit", "-m", "my commit"});\r\n\r\n// \u6267\u884c\u547d\u4ee4\r\nvar result = cmd.ExecuteAsync();\n'})}),"\n",(0,s.jsx)(n.h2,{id:"379-\u53cd\u9988\u4e0e\u5efa\u8bae",children:"37.9 \u53cd\u9988\u4e0e\u5efa\u8bae"}),"\n",(0,s.jsx)(n.admonition,{title:"\u4e0e\u6211\u4eec\u4ea4\u6d41",type:"note",children:(0,s.jsxs)(n.p,{children:["\u7ed9 Furion \u63d0 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/new?issue",children:"Issue"}),"\u3002"]})})]})}function j(e={}){const{wrapper:n}={...(0,l.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},1151:(e,n,r)=>{r.d(n,{Z:()=>o,a:()=>d});var s=r(7294);const l={},i=s.createContext(l);function d(e){const n=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:d(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]);