
#import <appkit/Listener.h>	// NXIsServicesMenuItemEnabled
#import "Filter.h"

@interface Check: Object
{
	int any;
}
@end

@implementation Check
- (void) filter: (Filter *) f flag: (char) ch
{
	NXPrintf(f->err, "usage: %s [menu...]\n", f->progname),
	NXFlush(f->err);
	exit(1);
}

- (int) filter: (Filter *) f arg: (const char *) menu
{
	if (menu)
	NXPrintf(f->out, "\"%s\" %s enabled\n", menu,
		(any |= NXIsServicesMenuItemEnabled(menu)) ? "is" : "is not");
	return 0;
}

- (int) filter: (Filter *) f exit: (int) code
{
	return any == 0;	// success if any is enabled
}
@end

int main (int argc, char * argv [])
{
	return [[[Filter alloc] initFor: [Check new]] run: argv];
}

