diff --git a/README.md b/README.md index 801f81b..89aa713 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ NPM-GITEA ========= -Connect to gitea (using tea configuration) and list packages +Since npm cannot easily search private gitea repositories, this tool can be used +to search instead + +Uses your connection to gitea (using tea configuration) and list packages SETUP ----- @@ -17,3 +20,10 @@ UNINSTALL ``` npm uninstall -g ``` + +USAGE +----- + +``` +npm-gitea {search} | --help | --{json|markdown} +``` diff --git a/index.js b/index.js index 103c771..498666c 100755 --- a/index.js +++ b/index.js @@ -12,6 +12,13 @@ const yaml = require("yaml"); const rawArgs = process.argv.slice(2); const asJSON = rawArgs.includes("--json"); const asMarkdown = rawArgs.includes("--markdown"); +if (rawArgs.includes("--help")) { + process.stdout.write(`USAGE: ${path.basename(process.argv[0])} {search} + --json - format as JSON + --markdown - format as Markdown table + --help - show help\n`) + process.exit(0) +} const query = rawArgs.find(arg => !arg.startsWith("--")) || null; // === CONFIG SEARCH === @@ -39,7 +46,7 @@ function findTeaConfig() { function loadGiteaLogin() { const configPath = findTeaConfig(); if (!configPath) { - console.error("❌ Could not find tea config.yml or tea.yml"); + console.error("Could not find tea config.yml or tea.yml"); process.exit(1); } @@ -48,16 +55,16 @@ function loadGiteaLogin() { const logins = parsed.logins || []; if (logins.length === 0) { - console.error("❌ No logins found in config"); + console.error("No logins found in config"); process.exit(1); } const login = logins.find((l) => l.default) || logins[0]; - debug(`🔧 Using config: ${configPath}`); - debug(`👤 Gitea user: ${login.user}`); - debug(`🌐 Gitea URL: ${login.url}`); - debug(`🔐 Auth token: ${login.token ? '[present]' : '[missing]'}`); + debug(`Using config: ${configPath}`); + debug(`Gitea user: ${login.user}`); + debug(`Gitea URL: ${login.url}`); + debug(`Auth token: ${login.token ? '[present]' : '[missing]'}`); return { baseUrl: login.url.replace(/\/$/, ""), @@ -133,7 +140,7 @@ async function listPackages() { printPlain(packages); } } catch (err) { - console.error("❌ Error:", err.message); + console.error("Error:", err.message); } }