]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/ListDevicesCommand.java
1 package org
.asamk
.signal
.commands
;
3 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
4 import net
.sourceforge
.argparse4j
.inf
.Subparser
;
6 import org
.asamk
.signal
.manager
.Manager
;
7 import org
.asamk
.signal
.util
.DateUtils
;
8 import org
.whispersystems
.signalservice
.api
.messages
.multidevice
.DeviceInfo
;
10 import java
.io
.IOException
;
11 import java
.util
.List
;
13 public class ListDevicesCommand
implements LocalCommand
{
16 public void attachToSubparser(final Subparser subparser
) {
20 public int handleCommand(final Namespace ns
, final Manager m
) {
21 if (!m
.isRegistered()) {
22 System
.err
.println("User is not registered.");
26 List
<DeviceInfo
> devices
= m
.getLinkedDevices();
27 for (DeviceInfo d
: devices
) {
28 System
.out
.println("Device " + d
.getId() + (d
.getId() == m
.getDeviceId() ?
" (this device)" : "") + ":");
29 System
.out
.println(" Name: " + d
.getName());
30 System
.out
.println(" Created: " + DateUtils
.formatTimestamp(d
.getCreated()));
31 System
.out
.println(" Last seen: " + DateUtils
.formatTimestamp(d
.getLastSeen()));
34 } catch (IOException e
) {