UNPKG

office-addin-usage-data

Version:

Provides infrastructure to send usage data events and exceptions.

44 lines (33 loc) 1.14 kB
#!/usr/bin/env node // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. import { Command } from "commander"; import { logErrorMessage } from "./log"; import * as commands from "./command"; /* global process */ const commander = new Command(); commander.name("office-addin-usage-data"); commander.version(process.env.npm_package_version || "(version not available)"); commander .command(`list`) .description(`Display the current usage data settings.`) .action(commands.listUsageDataSettings); commander .command(`off`) .description(`Turn off reporting of anonymous usage data.`) .action(commands.turnUsageDataOff); commander .command(`on`) .description(`Turn on reporting of anonymous usage data.`) .action(commands.turnUsageDataOn); // if the command is not known, display an error commander.on("command:*", function () { logErrorMessage(`The command syntax is not valid.\n`); process.exitCode = 1; commander.help(); }); if (process.argv.length > 2) { commander.parse(process.argv); } else { commander.help(); }