<commit_before>#!/usr/bin/env node


///Module dependencies. ///////////////////////////////////////

var http = require('http');
var fs = require('fs');
var shell = require('shelljs');
var colors = require('colors');
var jsonfile = require('jsonfile');
var prompt = require('prompt');

//redis object
var redis = require('redis');
var client;

/////////////////////// redis callbacks



//call to connect to the server and use the client class level variable
//only do this when using commands that need to connect to the server
// fun = the function we are going to call
function connectToRedisServer(fun)
{
  // //change to env variable
  client = redis.createClient("6379", "localhost");
  // //we need to send it our password
  // //change to env variable later
  // client.auth(PASSWORD);
  //called when the client successfully connects
  client.on('connect', function() {
      console.log('connected'.green);
      //check if we passed a function or not
      if(fun != null) {
        //call the passed function
        fun();
      }
  });

  //called when client gets an error
  client.on("error", function (err) {
      console.log("Error " + err);
  });

  client.on("end", function (err) {
      console.log("Connection Ended".red);
  });
}

function testDBConnection()
{
  connectToRedisServer();
  client.quit();
}

/////////////////////////////////////////////////

//get the config file
//The config file is used for companies to specify their own database IPs
var configFile;
//the static version number
var versionNumber = "0.0.1";

//Step 1
//read the config file immedately
readConfig();


/////////////////////////////////////////////////////////////////////

//the location of the process so we can add repos to the current location
var locationOfProcess;

//read the arguments
function readArgs()
{

  //check to see if we should process anything
  if(process.argv.length > 2)
  {
    //set locationOfProcess
    locationOfProcess = process.argv[1];
    // console.log(process.argv[2]);

    //check what our command is
    switch (process.argv[2]) {
      case "help":
          //show the commands avalible
          help();
          break;
      case "cache":
          //take the next arg after cachelocation and store it
          cachelocation();
          break;
      case "cachelocation":
          //log the cachelocation
          console.log("cache location: " + configFile.cachelocation.green);
          break;
      case "home":
          break;
      case "info":
          break;
      case "install":
          //check if the next parameter is -c or -cache for installing at the cache location
          //not at the current process
          break;
      case "list":
          break;
      case "login":
          break;
      case "register":
          //prompt the user with questions so they can add repo info to the database
          register();
          break;
      case "update":
          break;
      case "uninstall":
          //find the gpkg.json file and remove the name dependency
          break;
      case "unregister":
          break;
      case "testdb":
          testDBConnection();
          break;
      case "version":
          console.log("v: " + versionNumber);
          break;
  }

    // console.log(process.argv);
  }
  else {
    //run help command
    console.log("\n Error: Command Not Found");
    help();
  }

}

/////////////////////////////////////////////////////////////////////

//register a repo with a database
function register () {

  //the schema for the questions needed in the database
  var schema = {
    properties: {
      name: {
        pattern: /^[a-zA-Z\s\-]+$/,
        message: 'Name must be only letters, spaces, or dashes',
        required: true
      },
      password: {
        message: 'Does this package need a password? [Leave Blank If No]',<commit_msg>added port number and IP address to the configFile<commit_after>#!/usr/bin/env node


///Module dependencies. ///////////////////////////////////////

var http = require('http');
var fs = require('fs');
var shell = require('shelljs');
var colors = require('colors');
var jsonfile = require('jsonfile');
var prompt = require('prompt');

//redis object
var redis = require('redis');
var client;


/////////////////////////////////////////////////

//get the config file
//The config file is used for companies to specify their own database IPs
var configFile;
//the static version number
var versionNumber = "0.0.1";

//Step 1
//read the config file immedately
readConfig();


/////////////////////////////////////////////////////////////////////

//the location of the process so we can add repos to the current location
var locationOfProcess;

//read the arguments
function readArgs()
{

  //check to see if we should process anything
  if(process.argv.length > 2)
  {
    //set locationOfProcess
    locationOfProcess = process.argv[1];
    // console.log(process.argv[2]);

    //check what our command is
    switch (process.argv[2]) {
      case "help":
          //show the commands avalible
          help();
          break;
      case "cache":
          //take the next arg after cachelocation and store it
          cachelocation();
          break;
      case "cachelocation":
          //log the cachelocation
          console.log("cache location: " + configFile.cachelocation.green);
          break;
      case "home":
          break;
      case "info":
          break;
      case "install":
          //check if the next parameter is -c or -cache for installing at the cache location
          //not at the current process
          break;
      case "list":
          break;
      case "login":
          break;
      case "register":
          //prompt the user with questions so they can add repo info to the database
          register();
          break;
      case "update":
          break;
      case "uninstall":
          //find the gpkg.json file and remove the name dependency
          break;
      case "unregister":
          break;
      case "testdb":
          testDBConnection();
          break;
      case "version":
          console.log("v: " + versionNumber);
          break;
  }

    // console.log(process.argv);
  }
  else {
    //run help command
    console.log("\n Error: Command Not Found");
    help();
  }

}

/////////////////////////////////////////////////////////////////////


//call to connect to the server and use the client class level variable
//only do this when using commands that need to connect to the server
// fun = the function we are going to call
function connectToRedisServer(fun)
{
  // //change to env variable
  client = redis.createClient(configFile.port, configFile.ipaddress);
  // //we need to send it our password
  // //change to env variable later
  // client.auth(PASSWORD);
  //called when the client successfully connects
  client.on('connect', function() {
      console.log('connected'.green);
      //check if we passed a function or not
      if(fun != null) {
        //call the passed function
        fun();
      }
  });

  //called when client gets an error
  client.on("error", function (err) {
      console.log("Error " + err);
  });

  client.on("end", function (err) {
      console.log("Connection Ended".red);
  });
}

function testDBConnection()
{
  connectToRedisServer();
  client.quit();
}


//register a repo with a database
function register () {

  //the schema for the questions needed in the database
  var schema = {
    properties: {
      name: {
        pattern: /^[a-zA-Z\s\-]+$/,
        message: 'Name must be only letters, spaces, or dashes',
        required: true
      },
      password: {
        message: 'Does this package need a password? [Leave Blank If No]',
{'fraction_non_alphanumeric': 0.16698903932946485, 'fraction_numerical': 0.0025789813023855577, 'mean_word_length': 1.8483290488431876, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3027831', 'n_tokens_mistral': 2045, 'n_tokens_neox': 1997, 'n_words': 755}