Login
Artifact [1c5c7f7b32]
Login

Artifact 1c5c7f7b32b0ae44bb7fefd2a2564b1fcc599ce5:


/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 
/* vim: set ts=2 et sw=2 tw=80: */
/*
   Copyright (c) 2013 D. Richard Hipp
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the Simplified BSD License (also
   known as the "2-Clause License" or "FreeBSD License".)
  
   This program is distributed in the hope that it will be useful,
   but without any warranty; without even the implied warranty of
   merchantability or fitness for a particular purpose.
  
   Author contact information:
     drh@hwaci.com
     http://www.hwaci.com/drh/
  
  *****************************************************************************
   A simple tool for resolving symbolic names to UUIDs and RIDs.
*/

#include "fossil-scm/fossil-cli.h" /* Fossil App mini-framework */


static void fcli_local_help(){
  printf("Usage:\n\t%s [options] symbol [...symbol]\n\n", fcli.appName);

  puts("Resolves symbolic checkin names or "
       "partial UUIDs to full UUIDs and RIDs.\n");
}

int main(int argc, char * const * argv ){
  int rc = 0;
  char * sym = NULL;
  fsl_cx * f;
  fsl_db * db;
  int count = 0;
  fsl_id_t rid;
  fsl_uuid_str uuid;
  fcli.appHelp = fcli_local_help;
  rc = fcli_setup(argc, argv);
  if(FSL_RC_BREAK==rc) /* --help */ return 0;
  else if(rc) goto end;
  f = fcli.f;
  db = fsl_cx_db_repo(f);
  if(!db){
    rc = fsl_cx_err_set(f, FSL_RC_MISUSE,
                        "This app requires a repository db.");
    goto end;
  }
  if(fcli_has_unused_flags(0)) goto end;

  while( (sym = fcli_next_arg(1)) ){
    uuid = NULL;
    rid = 0;
    ++count;
    rc = fsl_sym_to_uuid(f, sym, FSL_CATYPE_ANY, &uuid, &rid);
    if(!rc){
      f_out("%s %7"FSL_ID_T_PFMT" %s\n",
             uuid, rid, sym);
    }
    fsl_free(sym);
    fsl_free(uuid);
    if(rc) goto end;
  }
  if(!count){
    fcli_help();
    rc = FSL_RC_MISUSE;
  }

  end:
  return fcli_end_of_main(rc);
}