// Exercise 1
// Write a C++ program which takes a number
// as a command line argument and creates a spacegroup
// object from it

#include <iostream>

// Include the core clipper functions
#include <clipper/clipper.h>

// Main program
int main (int argc, char** argv)
{
  // Check command line
  if (argc != 2) {
    std::cout << "Wrong number of arguments - enter a spacegroup number\n";
    exit(1);
  }
  // There should be a single argument (spacegroup number)
  // Acquire an integer value from the string (using Clipper String)
  clipper::String str(argv[1]);
  int sgnum = str.i();
  std::cout << "Spacegroup number is " << sgnum << "\n";

  // Make a spacegroup description
  clipper::Spgr_descr spgrd(sgnum);
  // Make a spacegroup object from the description
  clipper::Spacegroup spgr(spgrd);

  // Print some names to show the program has worked
  std::cout << "Spacegroup number:\t" << spgr.spacegroup_number() << "\n";
  std::cout << "           Hall  :\t" << spgr.symbol_hall() << "\n";
  std::cout << "           H-M   :\t" << spgr.symbol_hm() << "\n";
  std::cout << "           Laue  :\t" << spgr.symbol_laue() << "\n";
  // Print symops
  for (int i = 0; i < spgr.num_symops(); i++) {
    clipper::Symop op = spgr.symop(i);
    std::cout << "\t\t" << i+1 << ":\t" << op.format() << "\n";
  }
  // Finish
  exit(0);
}
