1 Commits

Author SHA1 Message Date
9a79e6a830 3.0.2: zsh completion completes baspkgs 2025-01-27 02:02:55 -05:00
5 changed files with 42 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ _artix_metro_completion() {
# Populate variables # Populate variables
repos=("${(s: :)ARTIX_DB}") repos=("${(s: :)ARTIX_DB}")
autorepos=("${(s: :)ARTIX_DB_MAP}") autorepos=("${(s: :)ARTIX_DB_MAP}")
pkgbase=("package") # TODO: populate cloned packages pkgbase=("${(s: :)$(artix-metro --completion pkgbase)}")
# Handle command and argument contexts # Handle command and argument contexts
_arguments -C \ _arguments -C \

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "artix-metro", "name": "artix-metro",
"version": "3.0.1", "version": "3.0.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "artix-metro", "name": "artix-metro",
"version": "3.0.1", "version": "3.0.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"artix-checkupdates": "1.0.1", "artix-checkupdates": "1.0.1",

View File

@@ -1,6 +1,6 @@
{ {
"name": "artix-metro", "name": "artix-metro",
"version": "3.0.1", "version": "3.0.2",
"description": "Automate pushing packages to Artix", "description": "Automate pushing packages to Artix",
"keywords": [ "keywords": [
"artix", "artix",

View File

@@ -30,14 +30,16 @@ function removeQuotes(str: string) {
class ArtoolsConfReader { class ArtoolsConfReader {
async readConf(): Promise<ArtoolsConf> { async readConf(silent: boolean = false): Promise<ArtoolsConf> {
const primaryLocation = path.join(os.homedir(), '.config', 'artools', 'artools-pkg.conf'); const primaryLocation = path.join(os.homedir(), '.config', 'artools', 'artools-pkg.conf');
const systemConf = path.join('/', 'etc', 'artools', 'artools-pkg.conf'); const systemConf = path.join('/', 'etc', 'artools', 'artools-pkg.conf');
try { try {
return await this.readConfFile(primaryLocation); return await this.readConfFile(primaryLocation);
} }
catch (ex) { catch (ex) {
console.error(`artools config at "${primaryLocation}" could not be read. ${ex}\nUsing system config "${systemConf}" instead.`); if (!silent) {
console.error(`artools config at "${primaryLocation}" could not be read. ${ex}\nUsing system config "${systemConf}" instead.`);
}
return await this.readConfFile(systemConf); return await this.readConfFile(systemConf);
} }
} }

View File

@@ -1,10 +1,12 @@
import * as fsp from 'node:fs/promises'; import * as fsp from 'node:fs/promises';
import * as readline from 'node:readline/promises'; import * as readline from 'node:readline/promises';
import path from 'node:path';
import clc from 'cli-color'; import clc from 'cli-color';
import JSON5 from 'json5'; import JSON5 from 'json5';
import { Writable } from 'stream'; import { Writable } from 'stream';
import { Pusher } from './pusher.mjs'; import { Pusher } from './pusher.mjs';
import { isPasswordRequired } from './runCommand.mjs'; import { isPasswordRequired } from './runCommand.mjs';
import { ArtoolsConfReader } from './artoolsconf.mjs';
import type { Job, ArtixpkgRepo } from './pusher.mts'; import type { Job, ArtixpkgRepo } from './pusher.mts';
/** /**
@@ -44,6 +46,7 @@ async function getGpgPass() {
} }
async function artixMetro() { async function artixMetro() {
let completion: boolean = false;
let job: Partial<Job> = { let job: Partial<Job> = {
increment: false, increment: false,
packages: [] packages: []
@@ -64,6 +67,29 @@ async function artixMetro() {
const iPlus = i + 1; const iPlus = i + 1;
const args = process.argv; const args = process.argv;
switch (true) { switch (true) {
case (arg === '--completion') && iPlus < args.length:
const comm = args[iPlus] as string;
completion = skipOne = true;
switch (comm) {
case ('pkgbase'):
(new ArtoolsConfReader()).readConf(true).then(async (conf) => {
try {
console.log(
(await fsp.readdir(path.join(conf.workspace, 'artixlinux'), { withFileTypes: true }))
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name).join(' '));
process.exit(0);
}
catch {
process.exit(1);
}
})
break;
default:
console.error(`command "${comm}" not recognized`)
break;
}
break;
case (arg === '--job' || arg === '-j') && iPlus < args.length: case (arg === '--job' || arg === '-j') && iPlus < args.length:
if (jobfile) { if (jobfile) {
console.error(`multiple jobfiles provided. aborting.`); console.error(`multiple jobfiles provided. aborting.`);
@@ -111,6 +137,10 @@ async function artixMetro() {
} }
}); });
if (completion) {
return;
}
if (helpFlag || (!jobfile && !job.repo)) { if (helpFlag || (!jobfile && !job.repo)) {
console.log([ console.log([
`\nUsage: artix-metro [OPTIONS] [commands]...`, `\nUsage: artix-metro [OPTIONS] [commands]...`,
@@ -148,6 +178,10 @@ async function artixMetro() {
} }
})(); })();
if (completion) {
return;
}
let pusher = new Pusher({ let pusher = new Pusher({
gpgpass: process.env['GPGPASS'] || (await getGpgPass()) || '' gpgpass: process.env['GPGPASS'] || (await getGpgPass()) || ''
}); });