diff --git a/client.js b/client.js index 35af258..7f05d84 100644 --- a/client.js +++ b/client.js @@ -14,6 +14,7 @@ const sdk = require("./sdk"); const PROFILE_DEFAULT = "default"; const PROFILE_PATH = ".hlt"; const SERVER_DEFAULT_URL = "https://lt.ctdn.net"; +const TOKEN_FREE = "FREE"; // create socket instance let socket = null; @@ -177,6 +178,7 @@ program "setting token (default generate FREE access token)", "" ) + .option("-a --access ", "setting token access type", TOKEN_FREE) .option("-c --client ", "setting client (auto generate uuid)", "") .option("-p --profile ", "setting profile name", PROFILE_DEFAULT) .action(async (options) => { @@ -203,6 +205,10 @@ program config.token = options.token; } + if (options.access) { + config.access = options.access; + } + if (options.client) { config.clientId = options.clientId; } @@ -215,6 +221,10 @@ program config.clientId = generateUUID(); } + if (!config.access) { + config.access = TOKEN_FREE; + } + if (!config.token) { console.log("Generating token..."); await sdk @@ -247,7 +257,7 @@ program } return port; }) - .option("-a, --access ", "setting access type (FREE)", "FREE") + .option("-a, --access ", "setting access type (FREE)", TOKEN_FREE) .option("-p, --profile ", "setting profile name", PROFILE_DEFAULT) .option("-h, --host ", "local host value", "localhost") .option("-o, --origin ", "change request origin") @@ -350,10 +360,10 @@ program } else if (type === "apiKey" || type === "key") { config.apiKey = value; } else if (type === "access") { - config.access = (value && value.toUpperCase().trim()) || "FREE"; + config.access = (value && value.toUpperCase().trim()) || TOKEN_FREE; // FREE - if (config.access === "FREE") { + if (config.access === TOKEN_FREE) { await sdk .getTokenFree(config.server) .then((resp) => {