Example #1
0
        public ParseCommand(ParseActivity parseActivity, AisStore aisStore, ILogger <ParseCommand> logger)
            : base("parse", "Parse file to AIS messages")
        {
            _logger = logger;

            Add(new Argument <string>("store", "AIS parsed store"));
            Add(new Argument <string[]>("file", "File(s) to analyze, can use wild card syntax"));
            Add(new Option("--recursive", "Recursive search if wild card syntax is used"));
            Add(new Option("--resetStore", "Reset (clear) the store"));
            Add(new Option <int?>("--max", "Maximum number of files to process"));

            Handler = CommandHandler.Create(async(string store, string[] file, bool recursive, bool resetStore, int?max, CancellationToken token) =>
            {
                _logger.LogInformation($"Store={store}");
                aisStore.SetStoreFolder(store);

                if (resetStore)
                {
                    await aisStore.RestStore();
                }

                await parseActivity.Parse(file, recursive, max, token);
            });
        }