#ifndef interact_h_included
#define interact_h_included

#include <stdio.h>
// should return non-zero to quit interaction
typedef int cmd_action(void* actiondata, void* state, char* line);

struct command {
  const char* name;
  cmd_action* action;
  void* actiondata; // specific to each action
  const char* desc;
};

void interact(void* state, struct command* commands, const char* prompt);

void runscript(void* state, struct command* commands, FILE* f);

// useful reusable commands

int cmd_exit(void* actiondata, void* state, char* line);
int cmd_help(void* actiondata, void* state, char* line);

// parse line into a float value and call fn(state,value)
int cmd_callwithfloat(void* fn, void* state, char* line);
#endif
