Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
Latest commit
157 lines (149 loc) · 6.98 KB
/
Copy pathProgram.cs
File metadata and controls
157 lines (149 loc) · 6.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
usingSystem.CommandLine;
usingShellDocs.CLI.Commands;
usingSpectre.Console;
namespaceShellDocs.CLI;
/* CLI entry point.
This scaffolding wires up the command tree so `shelldocs --help` produces the right shape. */
internalclassProgram
{
privateconststringLogo=@"
███████╗██╗ ██╗███████╗██╗ ██╗ ██████╗ ██████╗ ██████╗███████╗
██╔════╝██║ ██║██╔════╝██║ ██║ ██╔══██╗██╔═══██╗██╔════╝██╔════╝
███████╗███████║█████╗ ██║ ██║ ██║ ██║██║ ██║██║ ███████╗
╚════██║██╔══██║██╔══╝ ██║ ██║ ██║ ██║██║ ██║██║ ╚════██║
███████║██║ ██║███████╗███████╗███████╗██████╔╝╚██████╔╝╚██████╗███████║
╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═════╝ ╚═════╝ ╚═════╝╚══════╝
";
privatestaticintMain(string[]args)
{
varroot=newRootCommand("ShellDocs — the docs framework for .NET.");
root.Subcommands.Add(CreateInitCommand());
root.Subcommands.Add(CreateAddCommand());
root.Subcommands.Add(CreateDevCommand());
root.Subcommands.Add(CreateBuildCommand());
root.Subcommands.Add(CreatePreviewCommand());
returnroot.Parse(args).Invoke();
}
privatestaticCommandCreateInitCommand()
{
varpath=newArgument<string?>("path")
{
Description="Target directory for the new docs project (default: docs/<CwdName>.Docs). Ignored with --attach.",
Arity=ArgumentArity.ZeroOrOne
};
vardir=newOption<string>("--dir")
{
Description="Working directory (default: current dir). With --attach, the project directory.",
DefaultValueFactory= _ =>Directory.GetCurrentDirectory()
};
varattach=newOption<bool>("--attach")
{
Description="Augment an existing Blazor project in --dir instead of creating a new one. Emits SHELLDOCS_SETUP.md for manual Program.cs / App.razor patching."
};
varyes=newOption<bool>("--yes"){Description="Non-interactive mode with default options."};
vartheme=newOption<string>("--theme")
{
Description="Theme preset: shadcn, fuma, nextra.",
DefaultValueFactory= _ =>"shadcn"
};
varcmd=newCommand("init","Scaffold a new ShellDocs site (default) or attach to an existing Blazor project.")
{
path,dir,attach,yes,theme
};
cmd.SetAction(pr =>
{
AnsiConsole.Markup($"[blue]{Logo}[/]");
AnsiConsole.MarkupLine("[dim] the docs framework for .NET[/]");
AnsiConsole.WriteLine();
returnInitCommand.Run(
pr.GetValue(path),
pr.GetValue(dir)??Directory.GetCurrentDirectory(),
pr.GetValue(attach),
pr.GetValue(yes),
pr.GetValue(theme)??"shadcn");
});
returncmd;
}
privatestaticCommandCreateAddCommand()
{
vartemplate=newArgument<string>("template"){Description="Template: component, guide, page."};
varname=newArgument<string>("name"){Description="Name of the new page (PascalCase for component, kebab-case for guide/page)."};
vardir=newOption<string>("--dir")
{
Description="Project directory (default: current dir).",
DefaultValueFactory= _ =>Directory.GetCurrentDirectory()
};
varforce=newOption<bool>("--force"){Description="Overwrite an existing file with the same name."};
varcmd=newCommand("add","Scaffold a new doc page from a template into content/."){template,name,dir,force};
cmd.SetAction(pr =>AddCommand.Run(
pr.GetValue(template)??"",
pr.GetValue(name)??"",
pr.GetValue(dir)??Directory.GetCurrentDirectory(),
pr.GetValue(force)));
returncmd;
}
privatestaticCommandCreateDevCommand()
{
vardir=newOption<string>("--dir")
{
Description="Project directory (default: current dir).",
DefaultValueFactory= _ =>Directory.GetCurrentDirectory()
};
varport=newOption<int>("--port")
{
Description="Port to bind on.",
DefaultValueFactory= _ =>5000
};
varcmd=newCommand("dev","Start dev server with hot-reload for .razor / .cs / .md changes.")
{
dir,port
};
cmd.SetAction(pr =>
DevCommand.Run(
pr.GetValue(dir)??Directory.GetCurrentDirectory(),
pr.GetValue(port)));
returncmd;
}
privatestaticCommandCreateBuildCommand()
{
vardir=newOption<string>("--dir")
{
Description="Project directory (default: current dir).",
DefaultValueFactory= _ =>Directory.GetCurrentDirectory()
};
varoutput=newOption<string>("--output")
{
Description="Output directory for the static site.",
DefaultValueFactory= _ =>"publish"
};
varbaseHref=newOption<string?>("--base-href")
{
Description="Rewrite <base href> in index.html (e.g. \"/my-repo/\" for GH Pages subpaths)."
};
varspaFallback=newOption<bool>("--spa-fallback")
{
Description="Copy index.html → 404.html so client-side routes survive on GH Pages."
};
varcmd=newCommand("build","Produce a static site ready for GH Pages / Cloudflare / S3.")
{
dir,output,baseHref,spaFallback
};
cmd.SetAction(pr =>
BuildCommand.Run(
pr.GetValue(dir)??Directory.GetCurrentDirectory(),
pr.GetValue(output)??"publish",
pr.GetValue(baseHref),
pr.GetValue(spaFallback)));
returncmd;
}
privatestaticCommandCreatePreviewCommand()
{
varname=newArgument<string>("name"){Description="Component name to preview."};
varcmd=newCommand("preview","Render a single component in isolation for design review."){name};
cmd.SetAction(pr =>
{
AnsiConsole.MarkupLine($"[yellow]shelldocs preview {pr.GetValue(name)}[/] — not yet implemented.");
});
returncmd;
}
}