feat(cli): add command to generate systemd unit files
- Introduces a CLI tool for creating systemd .timer and .service units - Adds options for configuring unit names, commands, scheduling, and more - Supports dry-run mode and user-level unit file generation
This commit is contained in:
39
src/cli/create.ts
Normal file
39
src/cli/create.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Command } from '@cliffy/command';
|
||||
import { generateUnitFiles } from '../templates/unit-generator.ts';
|
||||
import { TimerOptions } from '../types/options.ts';
|
||||
|
||||
export const createCommand = new Command()
|
||||
.description('Erzeugt eine systemd .service und .timer Unit')
|
||||
.option(
|
||||
'--name <name:string>',
|
||||
'Name der Unit-Dateien (optional, wird sonst aus dem Exec generiert)',
|
||||
)
|
||||
.option(
|
||||
'--exec <cmd:string>',
|
||||
'Kommando, das durch systemd ausgeführt werden soll',
|
||||
{ required: true },
|
||||
)
|
||||
.option('--calendar <time:string>', 'OnCalendar-Ausdruck für den Timer', {
|
||||
required: true,
|
||||
})
|
||||
.option('--description <desc:string>', 'Beschreibung des Timers')
|
||||
.option('--user', 'Erstellt die Unit als User-Timer')
|
||||
.option('--output <dir:string>', 'Zielverzeichnis der Unit-Dateien')
|
||||
.option(
|
||||
'--after <target:string>',
|
||||
'Optionales After= für die Service-Unit',
|
||||
{ collect: true },
|
||||
)
|
||||
.option(
|
||||
'--environment <env:string>',
|
||||
'Environment-Variablen im Format KEY=VALUE',
|
||||
{ collect: true },
|
||||
)
|
||||
.option(
|
||||
'--logfile <file:string>',
|
||||
'Dateipfad für Log-Ausgabe (stdout/stderr)',
|
||||
)
|
||||
.option('--dry-run', 'Gibt die Unit-Dateien nur aus, ohne sie zu schreiben')
|
||||
.action(async (options: TimerOptions) => {
|
||||
await generateUnitFiles(options);
|
||||
});
|
9
src/cli/main.ts
Normal file
9
src/cli/main.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Command } from '@cliffy/command';
|
||||
import { createCommand } from './create.ts';
|
||||
|
||||
await new Command()
|
||||
.name('systemd-timer')
|
||||
.version('0.1.0')
|
||||
.description('CLI Tool zum Erzeugen von systemd .timer und .service Units')
|
||||
.command('create', createCommand)
|
||||
.parse(Deno.args);
|
Reference in New Issue
Block a user