Exemple #1
0
        private static void AddNormalCommands(Cli cli, ILog log, IStorage storage, ITwitterGateway twitter)
        {
            var credentials   = new KeyStored <Credentials>(storage, "Credentials", () => Credentials.Invalid);
            var tweetTasks    = new KeyStored <ScheduledTasks>(storage, "TweetTasks", () => new ScheduledTasks());
            var likeTasks     = new KeyStored <ScheduledTasks>(storage, "LikeTasks", () => new ScheduledTasks());
            var tweet         = new Tweet(twitter, log);
            var like          = new Like(twitter, log);
            var automatonData = new KeyStored <RandomLikeAutomatonData>(storage, "AutomatonData", () => new RandomLikeAutomatonData());
            var likeAutomaton = new RandomLikeAutomaton(automatonData, likeTasks, like, twitter, log);
            var rawCommands   = new List <Command>
            {
                new SetupCommand(credentials, log),
                new ViewCredentials(credentials, log),
                new ScheduleTweet(tweetTasks, tweet, log),
                new ViewTasks(tweetTasks, log),
                new Run(tweetTasks, likeTasks, cli, likeAutomaton, log),
                new Cancel(tweetTasks, log),
                tweet,
                like,
                new SetMaxLikes(automatonData, twitter, log)
            };

            cli.AddCommands(rawCommands
                            .Select(x => new WithDisplayedUsername(log, credentials, x))
                            .Concat(new List <ICommand> {
                new Help(rawCommands.ToDictionary(x => x.Name, x => x), log)
            })
                            .ToArray());
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            var storage = new JsonFileStorage("./data/");
            var twitter = new HttpTwitterClient(new KeyStored <Credentials>(storage, "Credentials", () => Credentials.Invalid));
            var log     = new WithDateTime(new ConsoleLog());

            var options = new KeyStored <AppOptions>(storage, nameof(AppOptions), () => new AppOptions()).Get();

            if (options.ShowBirdArt)
            {
                new DrawBirdLogo().Execute();
            }

            var interactiveCli = Init(log, storage, twitter);

            interactiveCli.AddCommand(new Exit());
            var cli = Init(log, storage, twitter);

            cli.AddCommand(new InteractiveMode(interactiveCli));

            RunApp(args, cli);
        }
    static void Main(string[] args)
    {
        var log        = new ConsoleLog();
        var storage    = JsonFileStorage.AppData("ProcessAssassin");
        var targetList = new KeyStored <ProcessTargetList>(storage, "targets", () => new ProcessTargetList());

        var defaultCommand = "run";
        var cmd            = args.Length > 0 ? args[0] : defaultCommand;
        var paramArgs      = args.Skip(1).ToArray();

        var currentTargets = targetList.Get();

        if (cmd.ToLowerInvariant() != "help")
        {
            log.Info($"Targeting {currentTargets.Count} Processes");
            currentTargets.ToList().ForEach(x => log.Info($"  {x}"));
        }

        new CommandsWithHelp("Process Assassin", "ProcessAssassin", log,
                             new Run(new WithDateTime(log), targetList),
                             new ViewCurrentProcessNames(log),
                             new AddTargetProcess(log, targetList))
        .Execute(cmd, paramArgs);
    }