mirror of
https://github.com/Dokploy/cli.git
synced 2026-06-15 20:25:22 +02:00
feat: add check server command
This commit is contained in:
29
src/commands/authenticate.ts
Normal file
29
src/commands/authenticate.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Command, Flags } from "@oclif/core";
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
|
||||
const configPath = path.join(__dirname, "..", "..", "config.json");
|
||||
|
||||
export default class Authenticate extends Command {
|
||||
static description = "Authenticate the user by saving server URL and token";
|
||||
|
||||
static flags = {
|
||||
token: Flags.string({
|
||||
char: "t",
|
||||
description: "Authentication token",
|
||||
required: true,
|
||||
}),
|
||||
url: Flags.string({ char: "u", description: "Server URL", required: true }),
|
||||
};
|
||||
|
||||
async run() {
|
||||
const { flags } = await this.parse(Authenticate);
|
||||
const config = {
|
||||
token: flags.token,
|
||||
url: flags.url,
|
||||
};
|
||||
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||
this.log("Authentication details saved successfully.");
|
||||
}
|
||||
}
|
||||
30
src/commands/check-server.ts
Normal file
30
src/commands/check-server.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import {Args, Command, Flags} from '@oclif/core'
|
||||
|
||||
export default class CheckServer extends Command {
|
||||
static override args = {
|
||||
file: Args.string({description: 'file to read'}),
|
||||
}
|
||||
|
||||
static override description = 'describe the command here'
|
||||
|
||||
static override examples = [
|
||||
'<%= config.bin %> <%= command.id %>',
|
||||
]
|
||||
|
||||
static override flags = {
|
||||
// flag with no value (-f, --force)
|
||||
force: Flags.boolean({char: 'f'}),
|
||||
// flag with a value (-n, --name=VALUE)
|
||||
name: Flags.string({char: 'n', description: 'name to print'}),
|
||||
}
|
||||
|
||||
public async run(): Promise<void> {
|
||||
const {args, flags} = await this.parse(CheckServer)
|
||||
|
||||
const name = flags.name ?? 'world'
|
||||
this.log(`hello ${name} from /Users/mauricio/Documents/Github/Personal/cli/src/commands/check-server.ts`)
|
||||
if (args.file && flags.force) {
|
||||
this.log(`you input --force and --file: ${args.file}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/commands/hello/greet.ts
Normal file
29
src/commands/hello/greet.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Command, Flags } from "@oclif/core";
|
||||
|
||||
export default class Greet extends Command {
|
||||
static args = {
|
||||
// Puedes agregar argumentos adicionales si lo necesitas
|
||||
};
|
||||
|
||||
static description = "Greet the user with a message";
|
||||
|
||||
static examples = [
|
||||
`<%= config.bin %> <%= command.id %> --name=Mau
|
||||
hello Mau!
|
||||
`,
|
||||
];
|
||||
|
||||
static flags = {
|
||||
name: Flags.string({
|
||||
char: "n",
|
||||
description: "name to greet",
|
||||
required: false,
|
||||
}),
|
||||
};
|
||||
|
||||
async run(): Promise<void> {
|
||||
const { flags } = await this.parse(Greet);
|
||||
const name = flags.name ?? "user";
|
||||
this.log(`hello ${name}!`);
|
||||
}
|
||||
}
|
||||
34
src/commands/hello/index.ts
Normal file
34
src/commands/hello/index.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Args, Command, Flags } from "@oclif/core";
|
||||
|
||||
export default class Hello extends Command {
|
||||
static args = {
|
||||
person: Args.string({
|
||||
description: "Person to say hello to",
|
||||
required: true,
|
||||
}),
|
||||
};
|
||||
|
||||
static description = "Say hello";
|
||||
|
||||
static examples = [
|
||||
`<%= config.bin %> <%= command.id %> friend --from oclif
|
||||
hello friend from oclif! (./src/commands/hello/index.ts)
|
||||
`,
|
||||
];
|
||||
|
||||
static flags = {
|
||||
from: Flags.string({
|
||||
char: "f",
|
||||
description: "Who is saying hello",
|
||||
required: true,
|
||||
}),
|
||||
};
|
||||
|
||||
async run(): Promise<void> {
|
||||
const { args, flags } = await this.parse(Hello);
|
||||
|
||||
this.log(
|
||||
`hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
19
src/commands/hello/world.ts
Normal file
19
src/commands/hello/world.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import {Command} from '@oclif/core'
|
||||
|
||||
export default class World extends Command {
|
||||
static args = {}
|
||||
|
||||
static description = 'Say hello world'
|
||||
|
||||
static examples = [
|
||||
`<%= config.bin %> <%= command.id %>
|
||||
hello world! (./src/commands/hello/world.ts)
|
||||
`,
|
||||
]
|
||||
|
||||
static flags = {}
|
||||
|
||||
async run(): Promise<void> {
|
||||
this.log('hello world! (./src/commands/hello/world.ts)')
|
||||
}
|
||||
}
|
||||
1
src/index.ts
Normal file
1
src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export {run} from '@oclif/core'
|
||||
Reference in New Issue
Block a user