# include "opihi.h"

int macro_delete (int argc, char **argv) {

  Command *cmd;
  Macro *macro;

  if (argc != 2) {
    fprintf (stderr, "USAGE: macro delete <macro>\n");
    return (FALSE);
  }

  macro = MatchMacro (argv[1], FALSE, TRUE);
  if (macro == NULL) {
    fprintf (stderr, "Macro %s not found\n", argv[1]);
    return (FALSE);
  }
  cmd = MatchCommand (argv[1], FALSE, TRUE);
  if (cmd == NULL) {
    fprintf (stderr, "programming error: macro exists but not command\n");
    return (FALSE);
  }

  DeleteMacro (macro);
  DeleteCommand (cmd);
  return (TRUE);
}

