-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new device subcommand (implement #70)
- Loading branch information
Showing
10 changed files
with
421 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"fileVersion": 1, | ||
"versions": { | ||
"argparse": "1.3.0", | ||
"arsd-official": "10.9.10", | ||
"automem": "0.6.9", | ||
"bindbc-freetype": "1.0.5", | ||
"bindbc-loader": "1.0.3", | ||
"bindbc-opengl": "1.0.5", | ||
"bindbc-sdl": "1.0.1", | ||
"botan": "1.13.6", | ||
"botan-math": "1.0.4", | ||
"cachetools": "0.4.1", | ||
"concepts": "0.0.9", | ||
"concurrency": "5.0.4", | ||
"dfl": {"version":"224d9348286620c8ea4854690a09e7380d6f5b2f","repository":"git+https://github.com/Dadoum/dfl.git"}, | ||
"dlangui": "0.10.4", | ||
"dqt": {"version":"6a44b55f3a3691da930cb9eefe2a745afe1b764d","repository":"git+https://github.com/tim-dlang/dqt.git"}, | ||
"dsfml": "2.1.1", | ||
"dxml": "0.4.4", | ||
"dynamic-loader": {"version":"65a8b8b8a6d44d47e63bddc985268592ecf47764","repository":"git+https://github.com/Dadoum/dynamicloader.git"}, | ||
"glx-d": "1.1.0", | ||
"gtk_d": "1.0.3", | ||
"icontheme": "1.2.3", | ||
"ikod-containers": "0.0.22", | ||
"inilike": "1.2.2", | ||
"intel-intrinsics": "1.11.15", | ||
"isfreedesktop": "0.1.1", | ||
"keyring": {"path":"../../keyring/"}, | ||
"memutils": "1.0.10", | ||
"mir-core": "1.6.0", | ||
"plist": "~master", | ||
"plist-d": {"version":"30d152e88767611e10048b25777ecb5f9075f87c","repository":"git+https://github.com/Dadoum/libplist-d.git"}, | ||
"progress": "5.0.2", | ||
"provision": {"version":"533dca306b86f9c7801354b78f5187addb58b740","repository":"git+https://github.com/Dadoum/Provision.git"}, | ||
"requests": "2.1.2", | ||
"sideloader": {"path":"../../"}, | ||
"silly": "1.2.0-dev.2", | ||
"slf4d": "2.4.3", | ||
"test_allocator": "0.3.4", | ||
"undead": "1.1.8", | ||
"unit-threaded": "0.10.8", | ||
"windows-headers": "1.0.5", | ||
"x11": "1.0.21", | ||
"xdgpaths": "0.2.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
module device; | ||
|
||
import std.algorithm; | ||
import std.array; | ||
import std.exception; | ||
import std.stdio; | ||
import std.sumtype; | ||
import std.typecons; | ||
|
||
import slf4d; | ||
import slf4d.default_provider; | ||
|
||
import botan.cert.x509.pkcs10; | ||
import botan.filters.data_src; | ||
|
||
import argparse; | ||
|
||
import server.developersession; | ||
|
||
import cli_frontend; | ||
|
||
@(Command("device").Description("Manage registered devices.")) | ||
struct DeviceCommand | ||
{ | ||
int opCall() | ||
{ | ||
return cmd.match!( | ||
(ListDevices cmd) => cmd(), | ||
(AddDevice cmd) => cmd(), | ||
(DeleteDevice cmd) => cmd() | ||
); | ||
} | ||
|
||
@SubCommands | ||
SumType!(ListDevices, AddDevice, DeleteDevice) cmd; | ||
} | ||
|
||
@(Command("list").Description("List registered devices.")) | ||
struct ListDevices | ||
{ | ||
mixin LoginCommand; | ||
|
||
@(NamedArgument("team").Description("Team ID")) | ||
string teamId = null; | ||
|
||
int opCall() | ||
{ | ||
auto log = getLogger(); | ||
|
||
string configurationPath = systemConfigurationPath(); | ||
|
||
scope provisioningData = initializeADI(configurationPath); | ||
scope adi = provisioningData.adi; | ||
scope akDevice = provisioningData.device; | ||
|
||
auto appleAccount = login(akDevice, adi); | ||
|
||
if (!appleAccount) { | ||
return 1; | ||
} | ||
|
||
auto teams = appleAccount.listTeams().unwrap(); | ||
|
||
string teamId = this.teamId; | ||
if (teamId != null) { | ||
teams = teams.filter!((elem) => elem.teamId == teamId).array(); | ||
} | ||
enforce(teams.length > 0, "No matching team found."); | ||
|
||
auto team = teams[0]; | ||
|
||
auto devices = appleAccount.listDevices!iOS(team).unwrap(); | ||
|
||
writefln!"You have %d devices registered."(devices.length); | ||
writeln("Currently registered devices:"); | ||
foreach (device; devices) { | ||
writefln!" - Device `%s` of UDID `%s` with the identifier `%s`"(device.name, device.deviceNumber, device.deviceId); | ||
} | ||
|
||
return 0; | ||
} | ||
} | ||
|
||
@(Command("add").Description("Register device.")) | ||
struct AddDevice | ||
{ | ||
mixin LoginCommand; | ||
|
||
@(NamedArgument("team").Description("Team ID")) | ||
string teamId = null; | ||
|
||
@(PositionalArgument(0).Description("Device name")) | ||
string name = void; | ||
|
||
@(PositionalArgument(1).Description("Device UDID")) | ||
string udid = void; | ||
|
||
int opCall() | ||
{ | ||
auto log = getLogger(); | ||
|
||
string configurationPath = systemConfigurationPath(); | ||
|
||
scope provisioningData = initializeADI(configurationPath); | ||
scope adi = provisioningData.adi; | ||
scope akDevice = provisioningData.device; | ||
|
||
auto appleAccount = login(akDevice, adi); | ||
|
||
if (!appleAccount) { | ||
return 1; | ||
} | ||
|
||
auto teams = appleAccount.listTeams().unwrap(); | ||
|
||
string teamId = this.teamId; | ||
if (teamId != null) { | ||
teams = teams.filter!((elem) => elem.teamId == teamId).array(); | ||
} | ||
enforce(teams.length > 0, "No matching team found."); | ||
|
||
auto team = teams[0]; | ||
|
||
auto devices = appleAccount.addDevice!iOS(team, name, udid).unwrap(); | ||
log.info("Success!"); | ||
|
||
return 0; | ||
} | ||
} | ||
|
||
@(Command("delete").Description("Unregister device.")) | ||
struct DeleteDevice | ||
{ | ||
mixin LoginCommand; | ||
|
||
@(NamedArgument("team").Description("Team ID")) | ||
string teamId = null; | ||
|
||
@(PositionalArgument(0).Description("Apple device's identifier (not UDID, check device list).")) | ||
string deviceId = void; | ||
|
||
int opCall() | ||
{ | ||
auto log = getLogger(); | ||
|
||
string configurationPath = systemConfigurationPath(); | ||
|
||
scope provisioningData = initializeADI(configurationPath); | ||
scope adi = provisioningData.adi; | ||
scope akDevice = provisioningData.device; | ||
|
||
auto appleAccount = login(akDevice, adi); | ||
|
||
if (!appleAccount) { | ||
return 1; | ||
} | ||
|
||
auto teams = appleAccount.listTeams().unwrap(); | ||
|
||
string teamId = this.teamId; | ||
if (teamId != null) { | ||
teams = teams.filter!((elem) => elem.teamId == teamId).array(); | ||
} | ||
enforce(teams.length > 0, "No matching team found."); | ||
|
||
auto team = teams[0]; | ||
|
||
auto devices = appleAccount.deleteDevice!iOS(team, deviceId).unwrap(); | ||
log.info("Success!"); | ||
|
||
return 0; | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"fileVersion": 1, | ||
"versions": { | ||
"argparse": "1.3.0", | ||
"arsd-official": "10.9.10", | ||
"automem": "0.6.9", | ||
"bindbc-freetype": "1.0.5", | ||
"bindbc-loader": "1.0.3", | ||
"bindbc-opengl": "1.0.5", | ||
"bindbc-sdl": "1.0.1", | ||
"botan": "1.13.6", | ||
"botan-math": "1.0.4", | ||
"cachetools": "0.4.1", | ||
"concepts": "0.0.9", | ||
"concurrency": "5.0.4", | ||
"dfl": {"version":"224d9348286620c8ea4854690a09e7380d6f5b2f","repository":"git+https://github.com/Dadoum/dfl.git"}, | ||
"dlangui": "0.10.4", | ||
"dqt": {"version":"6a44b55f3a3691da930cb9eefe2a745afe1b764d","repository":"git+https://github.com/tim-dlang/dqt.git"}, | ||
"dsfml": "2.1.1", | ||
"dxml": "0.4.4", | ||
"dynamic-loader": {"version":"65a8b8b8a6d44d47e63bddc985268592ecf47764","repository":"git+https://github.com/Dadoum/dynamicloader.git"}, | ||
"glx-d": "1.1.0", | ||
"gtk_d": "1.0.3", | ||
"icontheme": "1.2.3", | ||
"ikod-containers": "0.0.22", | ||
"inilike": "1.2.2", | ||
"intel-intrinsics": "1.11.15", | ||
"isfreedesktop": "0.1.1", | ||
"keyring": {"path":"../../keyring/"}, | ||
"memutils": "1.0.10", | ||
"mir-core": "1.6.0", | ||
"plist": "~master", | ||
"plist-d": {"version":"30d152e88767611e10048b25777ecb5f9075f87c","repository":"git+https://github.com/Dadoum/libplist-d.git"}, | ||
"progress": "5.0.2", | ||
"provision": {"version":"533dca306b86f9c7801354b78f5187addb58b740","repository":"git+https://github.com/Dadoum/Provision.git"}, | ||
"requests": "2.1.2", | ||
"sideloader": {"path":"../../"}, | ||
"silly": "1.2.0-dev.2", | ||
"slf4d": "2.4.3", | ||
"test_allocator": "0.3.4", | ||
"undead": "1.1.8", | ||
"unit-threaded": "0.10.8", | ||
"windows-headers": "1.0.5", | ||
"x11": "1.0.21", | ||
"xdgpaths": "0.2.5" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"fileVersion": 1, | ||
"versions": { | ||
"argparse": "1.3.0", | ||
"arsd-official": "10.9.10", | ||
"automem": "0.6.9", | ||
"bindbc-freetype": "1.0.5", | ||
"bindbc-loader": "1.0.3", | ||
"bindbc-opengl": "1.0.5", | ||
"bindbc-sdl": "1.0.1", | ||
"botan": "1.13.6", | ||
"botan-math": "1.0.4", | ||
"cachetools": "0.4.1", | ||
"concepts": "0.0.9", | ||
"concurrency": "5.0.4", | ||
"dfl": {"version":"224d9348286620c8ea4854690a09e7380d6f5b2f","repository":"git+https://github.com/Dadoum/dfl.git"}, | ||
"dlangui": "0.10.4", | ||
"dqt": {"version":"6a44b55f3a3691da930cb9eefe2a745afe1b764d","repository":"git+https://github.com/tim-dlang/dqt.git"}, | ||
"dsfml": "2.1.1", | ||
"dxml": "0.4.4", | ||
"dynamic-loader": {"version":"65a8b8b8a6d44d47e63bddc985268592ecf47764","repository":"git+https://github.com/Dadoum/dynamicloader.git"}, | ||
"glx-d": "1.1.0", | ||
"gtk_d": "1.0.3", | ||
"icontheme": "1.2.3", | ||
"ikod-containers": "0.0.22", | ||
"inilike": "1.2.2", | ||
"intel-intrinsics": "1.11.15", | ||
"isfreedesktop": "0.1.1", | ||
"keyring": {"path":"../../keyring/"}, | ||
"memutils": "1.0.10", | ||
"mir-core": "1.6.0", | ||
"plist": "~master", | ||
"plist-d": {"version":"30d152e88767611e10048b25777ecb5f9075f87c","repository":"git+https://github.com/Dadoum/libplist-d.git"}, | ||
"progress": "5.0.2", | ||
"provision": {"version":"533dca306b86f9c7801354b78f5187addb58b740","repository":"git+https://github.com/Dadoum/Provision.git"}, | ||
"requests": "2.1.2", | ||
"sideloader": {"path":"../../"}, | ||
"silly": "1.2.0-dev.2", | ||
"slf4d": "2.4.3", | ||
"test_allocator": "0.3.4", | ||
"undead": "1.1.8", | ||
"unit-threaded": "0.10.8", | ||
"windows-headers": "1.0.5", | ||
"x11": "1.0.21", | ||
"xdgpaths": "0.2.5" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.