From 36b70f2d49b4f250a15e1aa92869741d1c49253f Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Sun, 8 Oct 2023 00:08:31 +0800 Subject: [PATCH] fix command file naming --- TODO.md | 4 ---- .../commands/{DefaultCommand.ts => Default.ts} | 8 ++++---- src/command-line/commands/{ReplCommand.ts => Repl.ts} | 2 +- src/command-line/commands/{RunCommand.ts => Run.ts} | 2 +- src/command-line/commands/index.ts | 6 +++--- src/command-line/index.ts | 6 +++--- 6 files changed, 12 insertions(+), 16 deletions(-) rename src/command-line/commands/{DefaultCommand.ts => Default.ts} (82%) rename src/command-line/commands/{ReplCommand.ts => Repl.ts} (95%) rename src/command-line/commands/{RunCommand.ts => Run.ts} (97%) diff --git a/TODO.md b/TODO.md index eb8207c8..e69de29b 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +0,0 @@ -update ty -fix command file naming - -ambr 'import { ty } from "@xieyuheng/ty"' 'import { ty } from "@xieyuheng/ty"' diff --git a/src/command-line/commands/DefaultCommand.ts b/src/command-line/commands/Default.ts similarity index 82% rename from src/command-line/commands/DefaultCommand.ts rename to src/command-line/commands/Default.ts index 8ca127c8..095927ef 100644 --- a/src/command-line/commands/DefaultCommand.ts +++ b/src/command-line/commands/Default.ts @@ -1,12 +1,12 @@ import { Command, CommandRunner } from "@xieyuheng/command-line" import { ty } from "@xieyuheng/ty" import { app } from "../../app/index.js" -import * as Commands from "../commands" +import * as Commands from "./index.js" type Args = { path?: string } type Opts = { help?: boolean; version?: boolean } -export class DefaultCommand extends Command { +export class Default extends Command { name = "default" description = "Run an file" @@ -34,10 +34,10 @@ export class DefaultCommand extends Command { if (path === undefined) { const dir = process.cwd() - const command = new Commands.ReplCommand() + const command = new Commands.Repl() await command.execute({ dir }) } else { - const command = new Commands.RunCommand() + const command = new Commands.Run() await command.execute({ path }) } } diff --git a/src/command-line/commands/ReplCommand.ts b/src/command-line/commands/Repl.ts similarity index 95% rename from src/command-line/commands/ReplCommand.ts rename to src/command-line/commands/Repl.ts index da527352..bac8dcbd 100644 --- a/src/command-line/commands/ReplCommand.ts +++ b/src/command-line/commands/Repl.ts @@ -5,7 +5,7 @@ import { app } from "../../app" type Args = {} -export class ReplCommand extends Command { +export class Repl extends Command { name = "repl" description = "Open an interactive REPL" diff --git a/src/command-line/commands/RunCommand.ts b/src/command-line/commands/Run.ts similarity index 97% rename from src/command-line/commands/RunCommand.ts rename to src/command-line/commands/Run.ts index 99c76f4a..75d04404 100644 --- a/src/command-line/commands/RunCommand.ts +++ b/src/command-line/commands/Run.ts @@ -12,7 +12,7 @@ import { createURL } from "../../utils/createURL" type Args = { path: string } type Opts = {} -export class RunCommand extends Command { +export class Run extends Command { name = "run" description = "Run an inet program" diff --git a/src/command-line/commands/index.ts b/src/command-line/commands/index.ts index 9f6711e3..8129549f 100644 --- a/src/command-line/commands/index.ts +++ b/src/command-line/commands/index.ts @@ -1,4 +1,4 @@ export * from "@xieyuheng/command-line/lib/commands" -export * from "./DefaultCommand" -export * from "./ReplCommand" -export * from "./RunCommand" +export * from "./Default" +export * from "./Repl" +export * from "./Run" diff --git a/src/command-line/index.ts b/src/command-line/index.ts index a053cdd8..42820e6a 100644 --- a/src/command-line/index.ts +++ b/src/command-line/index.ts @@ -3,10 +3,10 @@ import * as Commands from "./commands" export function createCommandRunner(): CommandRunner { return new CommandRunners.CommonCommandRunner({ - defaultCommand: new Commands.DefaultCommand(), + defaultCommand: new Commands.Default(), commands: [ - new Commands.ReplCommand(), - new Commands.RunCommand(), + new Commands.Repl(), + new Commands.Run(), new Commands.CommonHelp(), ], })