Skip to content

Commit

Permalink
Merge pull request #15 from Pisyukaev:change-args-of-new-file-cmd
Browse files Browse the repository at this point in the history
Change arguments for creating new locale file
  • Loading branch information
Pisyukaev authored Nov 19, 2023
2 parents 7f2a9b9 + d34ae66 commit a19bdde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
22 changes: 7 additions & 15 deletions src/commands/newLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,27 @@ export const description = 'Create new localization file from master file';

export function builder(yargs: Argv) {
return yargs
.option('name', {
alias: 'n',
desc: 'Name of new localization file',
demandOption: true,
type: 'string'
})
.option('master', {
alias: 'm',
desc: 'Master localization file',
demandOption: true,
type: 'string'
})
.option('directory', {
alias: 'dir',
desc: 'Directory of localization files',
type: 'string',
default: 'mock'
.option('name', {
alias: 'n',
desc: 'Name of new localization file',
demandOption: true,
type: 'string'
})
.usage(`\nExample:\n $0 ${command} -n strings-kz.xml -m strings.xml`);
}

export async function handler({
name,
master,
directory
master
}: ArgumentsCamelCase<{
name: string;
master: string;
directory: string;
}>) {
newLocale({ name, master, directory });
newLocale({ name, master });
}
12 changes: 4 additions & 8 deletions src/modifiers/newLocale.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import * as fs from 'fs';

export function newLocale(options: {
name: string;
master: string;
directory: string;
}) {
const { name, master, directory } = options;
export function newLocale(options: { name: string; master: string }) {
const { name, master } = options;

fs.copyFile(`${directory}/${master}`, `${directory}/${name}`, (err) => {
fs.copyFile(master, name, (err) => {
if (err) {
console.error(err);

return;
}
console.log(`${master} was copied to ${directory}/${name}`);
console.log(`${master} was copied to ${name}`);
});
}

0 comments on commit a19bdde

Please sign in to comment.