コード例 #1
0
        protected override async Task ExecuteAsync(IConsole console)
        {
            if (Name != default && Id != default)
            {
                await ErrorAsync("Please specify either name or id, not both");

                return;
            }

            var user = Name != default
                ? await ServerAccessor.GetUserByNameAsync(Name)
                : Id != default
                ? await ServerAccessor.GetUserByIdAsync(Id)
                : await ClientAccessor.GetCurrentUserAync();

            if (user == null)
            {
                await WarnLineAsync("User not found");

                return;
            }

            var miners = Name != default
                ? await ServerAccessor.ListMinersByNameAsync(Name)
                : Id != default
                ? await ServerAccessor.ListMinersByIdAsync(Id)
                : await ClientAccessor.ListOwnedMinersAsync();


            await InfoLineAsync($" [ {user.Name}   |   User Info ] ");

            await InfoLineAsync($"[ID]             |  {user.Id}");
            await InfoLineAsync($"[Miner Count]    |  {user.MinerState.MinerCount}");
            await InfoLineAsync($"[Plot Count]     |  {user.MinerState.PlotCount}");
            await InfoLineAsync($"[Plot Minutes]   |  {user.MinerState.PlotMinutes}");

            await WriteLineAsync();

            await InfoLineAsync($" [ {user.Name}   |   Miner Info ] ");

            if (miners.Count == 0)
            {
                await WarnLineAsync("None");

                return;
            }

            int idLength   = miners.Max(x => x.Id.ToString().Length) + 2;
            int nameLength = miners.Max(x => x.Name.Length);

            await InfoLineAsync($"Id{Space(idLength)}Name{Space(nameLength)}PM");

            foreach (var miner in miners)
            {
                await WriteLineAsync($"{miner.Id}    {miner.Name}    {miner.PlotMinutes}");
            }
        }