Skip to content

Commit

Permalink
update peers descriptions, show -> info, add json to info (#5235)
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-if authored Aug 13, 2024
1 parent 31cbe8f commit bed1b3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/peers/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'

export class AddCommand extends IronfishCommand {
static description = `Attempt to connect to a peer through websockets`
static description = `attempt to connect to a peer`

static args = {
address: UrlArg({
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/peers/banned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { table, TableColumns, TableFlags } from '../../ui'
const { sort, ...tableFlags } = TableFlags

export class BannedCommand extends IronfishCommand {
static description = `List all banned peers`
static description = `list banned peers`

static flags = {
...RemoteFlags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { GetPeerMessagesResponse, GetPeerResponse, TimeUtils } from '@ironfish/s
import { Args } from '@oclif/core'
import colors from 'colors/safe'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'
import { JsonFlags, RemoteFlags } from '../../flags'

type GetPeerResponsePeer = NonNullable<GetPeerResponse['peer']>
type GetPeerMessagesResponseMessages = GetPeerMessagesResponse['messages'][0]

export class ShowCommand extends IronfishCommand {
static description = `Display info about a peer`
export class PeerInfo extends IronfishCommand {
static description = `show peer information`
static enableJsonFlag = true
static hiddenAliases = ['peers:show']

static args = {
identity: Args.string({
Expand All @@ -22,16 +24,17 @@ export class ShowCommand extends IronfishCommand {

static flags = {
...RemoteFlags,
...JsonFlags,
}

async start(): Promise<void> {
const { args } = await this.parse(ShowCommand)
async start(): Promise<unknown> {
const { args } = await this.parse(PeerInfo)
const { identity } = args

await this.sdk.client.connect()
const client = await this.connectRpc()
const [peer, messages] = await Promise.all([
this.sdk.client.peer.getPeer({ identity }),
this.sdk.client.peer.getPeerMessages({ identity }),
client.peer.getPeer({ identity }),
client.peer.getPeerMessages({ identity }),
])

if (peer.content.peer === null) {
Expand All @@ -48,7 +51,10 @@ export class ShowCommand extends IronfishCommand {
}
}

this.exit(0)
return {
...peer.content,
...messages.content,
}
}

renderPeer(peer: GetPeerResponsePeer): string {
Expand Down

0 comments on commit bed1b3c

Please sign in to comment.