<commit_before>/**
* Copyright (c) Microsoft.  All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* You can test sample commands get loaded by xplat by following steps:
* a. Copy the folder to '<repository root>\lib\commands\arm'
* b. Under <repository root>, run 'node bin/azure config mode arm'
* c. Run 'node bin/azure', you should see 'sample' listed as a command set
* d. Run 'node bin/azure', you should see 'create', "delete", etc 
      showing up in the help text 
*/

'use strict';

var util = require('util');

var profile = require('../../../util/profile');
var utils = require('../../../util/utils');

var sampleUtils = require('./sampleUtils');

var $ = utils.getLocaleString;

exports.init = function (cli) {
  var log = cli.output;

  var sample = cli.category('sample')
    .description($('Commands to manage your Azure samples'));

  sample.command('create [sampleName]')
    .description($('Create a sample'))
    .option('--sampleName <sampleName>', $('the name of the new sample'))
    .option('--subscription <subscription>', $('the subscription identifier'))
    .execute(function (sampleName, options, _) {
      var subscription = profile.current.getSubscription(options.subscription);
      var client = utils.getSampleClient(subscription);

      if (!sampleName) {
        return cli.missingArgument('sampleName');
      }

      var progress = cli.interaction.progress(util.format($('Creating sample %s'), sampleName));
      var result;
      try {
        result = client.samples.create(sampleName, _);
      } finally {
        progress.end();
      }

      var samples = [];
      sample.push(result.sample);
      cli.interaction.formatOutput(samples, function (data) {
          if (data.length === 0) {
            log.info($('No samples defined'));
          } else {
            log.table(data, displayASample);
          }
      });
    });

  sample.command('delete [sampleName]')
    .description($('Create a sample'))
    .option('--sampleName <sampleName>', $('the name of the sample to delete'))
    .option('--subscription <subscription>', $('the subscription identifier'))
    .execute(function (sampleName, options, _) {
      var subscription = profile.current.getSubscription(options.subscription);
      var client = utils.getSampleClient(subscription);
      
      if (!sampleName) {
        return cli.missingArgument('sampleName');
      }

      var progress = cli.interaction.progress(util.format($('Deleting sample %s'), sampleName));

      var result;
      try {
        result = client.samples.delete(sampleName, _);
      } finally {
        progress.end();
      }
    });

  sample.command('list')
    .description($('Get all available samples'))
    .execute(function (options, _) {
      var subscription = profile.current.getSubscription(options.subscription);
      var client = utils.getSampleClient(subscription);
      var progress = cli.interaction.progress($('Listing samples'));
      var result;<commit_msg>Update sample-service.sample._js<commit_after>/**
* Copyright (c) Microsoft.  All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* You can test sample commands get loaded by xplat by following steps:
* a. Copy the folder to '<repository root>\lib\commands\arm'
* b. Under <repository root>, run 'node bin/azure config mode arm'
* c. Run 'node bin/azure', you should see 'sample' listed as a command set
* d. Run 'node bin/azure', you should see 'create', "delete", etc 
      showing up in the help text 
*/

'use strict';

var util = require('util');

var profile = require('../../../util/profile');
var utils = require('../../../util/utils');

var sampleUtils = require('./sampleUtils');

var $ = utils.getLocaleString;

exports.init = function (cli) {
  var log = cli.output;

  var sample = cli.category('sample')
    .description($('Commands to manage your Azure samples'));

  sample.command('create [sampleName]')
    .description($('Create a sample'))
    .option('--sampleName <sampleName>', $('the name of the new sample'))
    .option('--subscription <subscription>', $('the subscription identifier'))
    .execute(function (sampleName, options, _) {
      var subscription = profile.current.getSubscription(options.subscription);
      var client = utils.getSampleClient(subscription);

      if (!sampleName) {
        return cli.missingArgument('sampleName');
      }

      var progress = cli.interaction.progress(util.format($('Creating sample %s'), sampleName));
      var result;
      try {
        result = client.samples.create(sampleName, _);
      } finally {
        progress.end();
      }

      var samples = [];
      sample.push(result.sample);
      cli.interaction.formatOutput(samples, function (data) {
          if (data.length === 0) {
            log.info($('No samples defined'));
          } else {
            log.table(data, displayASample);
          }
      });
    });

  sample.command('delete [sampleName]')
    .description($('Create a sample'))
    .option('--sampleName <sampleName>', $('the name of the sample to delete'))
    .option('--subscription <subscription>', $('the subscription identifier'))
    .execute(function (sampleName, options, _) {
      var subscription = profile.current.getSubscription(options.subscription);
      var client = utils.getSampleClient(subscription);
      
      if (!sampleName) {
        return cli.missingArgument('sampleName');
      }

      var progress = cli.interaction.progress(util.format($('Deleting sample %s'), sampleName));

      var result;
      try {
        result = client.samples.delete(sampleName, _);
      } finally {
        progress.end();
      }
    });

  sample.command('list')
    .description($('Get all available samples'))
    .option('--subscription <subscription>', $('the subscription identifier'))
    .execute(function (options, _) {
      var subscription = profile.current.getSubscription(options.subscription);
      var client = utils.getSampleClient(subscription);
      var progress = cli.interaction.progress($('Listing samples'));
      var result;
{'fraction_non_alphanumeric': 0.1357364122782315, 'fraction_numerical': 0.0014080540692762602, 'mean_word_length': 3.2204396910279263, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '9448', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1912, 'n_words': 599}