From d5cf1b87a838aef019dc84d1d070fece88d8899d Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Fri, 25 Mar 2022 18:43:46 +0000 Subject: [PATCH] Use NXAPI_DATA_PATH and ZNC_PROXY_URL environment variables --- src/cli.ts | 2 +- src/cli/nso.ts | 3 ++- src/cli/nso/auth.ts | 4 ++-- src/cli/pctl/auth.ts | 4 ++-- src/cli/splatnet2.ts | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 1dc4cbc..61f620b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -8,7 +8,7 @@ const debug = createDebug('cli'); const yargs = Yargs(process.argv.slice(2)).option('data-path', { describe: 'Data storage path', type: 'string', - default: paths.data, + default: process.env.NXAPI_DATA_PATH || paths.data, }); export type Arguments = YargsArguments; diff --git a/src/cli/nso.ts b/src/cli/nso.ts index e328676..8bc46ac 100644 --- a/src/cli/nso.ts +++ b/src/cli/nso.ts @@ -10,13 +10,14 @@ export const desc = 'Nintendo Switch Online'; export function builder(yargs: Argv) { for (const command of Object.values(commands)) { - // @ts-expect-error + // @ts-ignore yargs.command(command); } return yargs.option('znc-proxy-url', { describe: 'URL of Nintendo Switch Online app API proxy server to use', type: 'string', + default: process.env.ZNC_PROXY_URL, }); } diff --git a/src/cli/nso/auth.ts b/src/cli/nso/auth.ts index 8fa699d..4889b2e 100644 --- a/src/cli/nso/auth.ts +++ b/src/cli/nso/auth.ts @@ -53,7 +53,7 @@ export async function handler(argv: ArgumentsCamelCase) { console.log(''); console.log(authoriseurl); console.log(''); - + console.log('2. On the "Linking an External Account" page, right click "Select this person" and copy the link. It should start with "npf71b963c1b7b6d119://auth".'); console.log(''); @@ -79,7 +79,7 @@ export async function handler(argv: ArgumentsCamelCase) { if (argv.auth) { const storage = await initStorage(argv.dataPath); - + const {nso, data} = await getToken(storage, token.session_token, argv.zncProxyUrl); console.log('Authenticated as Nintendo Account %s (NA %s, NSO %s)', diff --git a/src/cli/pctl/auth.ts b/src/cli/pctl/auth.ts index 14b6332..41ffe2e 100644 --- a/src/cli/pctl/auth.ts +++ b/src/cli/pctl/auth.ts @@ -66,7 +66,7 @@ export async function handler(argv: ArgumentsCamelCase) { console.log(''); console.log(authoriseurl); console.log(''); - + console.log('2. On the "Linking an External Account" page, right click "Select this person" and copy the link. It should start with "npf54789befb391a838://auth".'); console.log(''); @@ -93,7 +93,7 @@ export async function handler(argv: ArgumentsCamelCase) { if (argv.auth) { const storage = await initStorage(argv.dataPath); - + const {moon, data} = await getPctlToken(storage, token.session_token); console.log('Authenticated as Nintendo Account %s (%s)', diff --git a/src/cli/splatnet2.ts b/src/cli/splatnet2.ts index d23ae5d..683671e 100644 --- a/src/cli/splatnet2.ts +++ b/src/cli/splatnet2.ts @@ -17,6 +17,7 @@ export function builder(yargs: Argv) { return yargs.option('znc-proxy-url', { describe: 'URL of Nintendo Switch Online app API proxy server to use', type: 'string', + default: process.env.ZNC_PROXY_URL, }).option('auto-update-session', { alias: ['auto-update-iksm-session'], describe: 'Automatically obtain and refresh the iksm_session cookie',