Skip to content

Commit

Permalink
fix: revert root call for interactive actions (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
y3owk1n authored Dec 2, 2024
1 parent 137c0e4 commit 9f14d72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Before using EnvCopy CLI, ensure you have the following prerequisites:

1. Running `cpenv` for the first time will prompt you to setup your `env-files` folder.

- You can set it to any folder you like, but the default is `~/.env-files`
- You can set it to any folder you like, but the default is `~/.env-files`. I personally set it to an icloud drive path.

2. Organize your projects within your chosen directory. Each project should have its own subdirectory.

Expand Down Expand Up @@ -81,19 +81,13 @@ brew install y3owk1n/tap/cpenv

Go to your project directory and run the following command in your terminal:

```bash
cpenv // without any subcommands will go into interactive mode
```

This will launch the interactive mode, guiding you through project selection, file copying and backups.

By supplying subcommands, you can skip the action flow

```bash
cpenv copy [options] // start copy interactive flow
cpenv backup // start backup interactive flow
```

This will launch the interactive mode, guiding you through project selection, file copying and backups.

### Options

#### For root
Expand All @@ -115,7 +109,6 @@ cpenv backup // start backup interactive flow
Interactive Mode

```bash
cpenv // choose action flow
cpenv copy [options] // start copy flow
cpenv backup // start backup flow
```
Expand Down
21 changes: 1 addition & 20 deletions src/core/init/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,15 @@ import {
getCurrentVersion,
} from "@/utils/version";
import type { Command } from "commander";
import { prepareBackup } from "../backup";
import { backupCommanderInit } from "../backup/command";
import { prepareCopy } from "../copy";
import { copyCommanderInit } from "../copy/command";
import { promptToSelectAction } from "./prompt";

export function commanderInit(program: Command) {
const name = getCurrentName();
const description = getCurrentDescription();
const version = getCurrentVersion();

program
.name(name)
.description(description)
.version(version)
.action(async () => {
const { action } = await promptToSelectAction();

if (action === "copy") {
await prepareCopy(program.opts);
return;
}

if (action === "backup") {
await prepareBackup();
return;
}
});
program.name(name).description(description).version(version);

copyCommanderInit(program);

Expand Down

0 comments on commit 9f14d72

Please sign in to comment.