Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/main/kotlin/spp/cli/commands/admin/Reset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package spp.cli.commands.admin
import com.github.ajalt.clikt.core.CliktCommand
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.system.ResetMutation
Expand All @@ -38,7 +39,19 @@ class Reset : CliktCommand() {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.reset)
if (Main.standalone) exitProcess(0)
if (PlatformCLI.verbose) {
if (response.data!!.reset) {
echo("Successfully reset the platform.")
} else {
echo("Failed to reset the platform.", err = true)
}
} else {
echo(response.data!!.reset)
}
if (response.data!!.reset) {
if (Main.standalone) exitProcess(0)
} else {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ class AddAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(JsonCleaner.cleanJson(MapJsonWriter().let {
it.beginObject()
AddAccessPermission.toJson(it, CustomScalarAdapters.Empty, response.data!!.addAccessPermission)
it.endObject()
(it.root() as LinkedHashMap<*, *>)
}).encodePrettily())
if (PlatformCLI.verbose) {
echo(JsonCleaner.cleanJson(MapJsonWriter().let {
it.beginObject()
AddAccessPermission.toJson(it, CustomScalarAdapters.Empty, response.data!!.addAccessPermission)
it.endObject()
(it.root() as LinkedHashMap<*, *>)
}).encodePrettily())
} else {
echo("Added access permission with id ${response.data!!.addAccessPermission.id}")
echo("Location patterns: ${response.data!!.addAccessPermission.locationPatterns!!}")
echo("Type: ${response.data!!.addAccessPermission.type}")
}
if (Main.standalone) exitProcess(0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,19 @@ class AddRoleAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.addRoleAccessPermission)
if (Main.standalone) exitProcess(0)
if (PlatformCLI.verbose) {
if (response.data!!.addRoleAccessPermission) {
echo("Added access permission $id to role $role")
} else {
echo("Could not add access permission $id to role $role, does the role already have it?", err = true)
}
} else {
echo(response.data!!.addRoleAccessPermission)
}
if (response.data!!.addRoleAccessPermission) {
if (Main.standalone) exitProcess(0)
} else {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,19 @@ class RemoveAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.removeAccessPermission)
if (Main.standalone) exitProcess(0)
if (PlatformCLI.verbose) {
if (response.data!!.removeAccessPermission) {
echo("Removed access permission $id")
} else {
echo("Failed to remove access permission $id, does it exist?", err = true)
}
} else {
echo(response.data!!.removeAccessPermission)
}
if (response.data!!.removeAccessPermission) {
if (Main.standalone) exitProcess(0)
} else {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,19 @@ class RemoveRoleAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.removeRoleAccessPermission)
if (Main.standalone) exitProcess(0)
if (PlatformCLI.verbose) {
if (response.data!!.removeRoleAccessPermission) {
echo("Removed access permission $id from role $role")
} else {
echo("Failed to remove access permission $id from role $role, does the role have it?")
}
} else {
echo(response.data!!.removeRoleAccessPermission)
}
if (response.data!!.removeRoleAccessPermission) {
if (Main.standalone) exitProcess(0)
} else {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}
}
}
11 changes: 9 additions & 2 deletions src/main/kotlin/spp/cli/commands/admin/client/AddClientAccess.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package spp.cli.commands.admin.client
import com.github.ajalt.clikt.core.CliktCommand
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.client.AddClientAccessMutation
Expand All @@ -38,8 +39,14 @@ class AddClientAccess : CliktCommand() {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.addClientAccess.id!!)
echo(response.data!!.addClientAccess.secret!!)
if (PlatformCLI.verbose) {
echo("Added client access");
echo("Id: ${response.data!!.addClientAccess.id!!}")
echo("Secret: ${response.data!!.addClientAccess.secret!!}")
} else {
echo(response.data!!.addClientAccess.id!!)
echo(response.data!!.addClientAccess.secret!!)
}
if (Main.standalone) exitProcess(0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.client.RemoveClientAccessMutation
Expand All @@ -41,7 +42,19 @@ class RemoveClientAccess : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.removeClientAccess)
if (Main.standalone) exitProcess(0)
if (PlatformCLI.verbose) {
if (response.data!!.removeClientAccess) {
echo("Removed client access $id")
} else {
echo("Failed to remove client access $id, does it exist?", err = true)
}
} else {
echo(response.data!!.removeClientAccess)
}
if (response.data!!.removeClientAccess) {
if (Main.standalone) exitProcess(0)
} else {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.client.UpdateClientAccessMutation
Expand All @@ -41,7 +42,12 @@ class UpdateClientAccess : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.updateClientAccess.secret!!)
if (PlatformCLI.verbose) {
echo("Update client access for id $id")
echo("New secret: ${response.data!!.updateClientAccess.secret!!}")
} else {
echo(response.data!!.updateClientAccess.secret!!)
}
if (Main.standalone) exitProcess(0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.developer.AddDeveloperMutation
Expand All @@ -41,7 +42,11 @@ class AddDeveloper : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.addDeveloper.accessToken!!)
if (PlatformCLI.verbose) {
echo("Added developer $id with token ${response.data!!.addDeveloper.accessToken!!}")
} else {
echo(response.data!!.addDeveloper.accessToken!!)
}
if (Main.standalone) exitProcess(0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.developer.RefreshDeveloperTokenMutation
Expand All @@ -41,7 +42,12 @@ class RefreshDeveloperToken : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.refreshDeveloperToken.accessToken!!)
if (PlatformCLI.verbose) {
echo("Refreshed developer token for id $id")
echo("New access token: ${response.data!!.refreshDeveloperToken.accessToken!!}")
} else {
echo(response.data!!.refreshDeveloperToken.accessToken!!)
}
if (Main.standalone) exitProcess(0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.developer.RemoveDeveloperMutation
Expand All @@ -41,7 +42,19 @@ class RemoveDeveloper : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

echo(response.data!!.removeDeveloper)
if (Main.standalone) exitProcess(0)
if (PlatformCLI.verbose) {
if (response.data!!.removeDeveloper) {
echo("Removed developer $id")
} else {
echo("Failed to remove developer $id, does it exist?", err = true)
}
} else {
echo(response.data!!.removeDeveloper)
}
if (response.data!!.removeDeveloper) {
if (Main.standalone) exitProcess(0)
} else {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.types.enum
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.permission.AddRolePermissionMutation
Expand All @@ -44,6 +45,18 @@ class AddRolePermission : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

if (PlatformCLI.verbose) {
if (response.data!!.addRolePermission) {
echo("Added permission ${permission.name} to role ${role}")
} else {
echo(
"Failed to add permission ${permission.name} to role ${role}, does the role already have it?",
err = true
)
}
} else {
echo(response.data!!.addRolePermission)
}
if (response.data!!.addRolePermission) {
if (Main.standalone) exitProcess(0)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.permission.RemoveRolePermissionMutation
Expand All @@ -42,6 +43,18 @@ class RemoveRolePermission : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

if (PlatformCLI.verbose) {
if (response.data!!.removeRolePermission) {
echo("Removed permission $permission from role $role")
} else {
echo(
"Failed to remove permission $permission from role $role, does the role have it?",
err = true
)
}
} else {
echo(response.data!!.removeRolePermission)
}
if (response.data!!.removeRolePermission) {
if (Main.standalone) exitProcess(0)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.role.AddDeveloperRoleMutation
Expand All @@ -42,6 +43,13 @@ class AddDeveloperRole : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

if (PlatformCLI.verbose) {
if (response.data!!.addDeveloperRole) {
echo("Added role $role to developer $id")
} else {
echo("Failed to add role $role to developer $id, do they already have it?", err = true)
}
}
if (response.data!!.addDeveloperRole) {
if (Main.standalone) exitProcess(0)
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/spp/cli/commands/admin/role/AddRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.role.AddRoleMutation
Expand All @@ -41,6 +42,15 @@ class AddRole : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

if (PlatformCLI.verbose) {
if (response.data!!.addRole) {
echo("Added role $role")
} else {
echo("Failed to add role $role, does it already exist?", err = true)
}
} else {
echo(response.data!!.addRole)
}
if (response.data!!.addRole) {
if (Main.standalone) exitProcess(0)
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/spp/cli/commands/admin/role/RemoveDeveloperRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.role.RemoveDeveloperRoleMutation
Expand All @@ -42,6 +43,15 @@ class RemoveDeveloperRole : CliktCommand(printHelpOnEmptyArgs = true) {
if (Main.standalone) exitProcess(-1) else return@runBlocking
}

if (PlatformCLI.verbose) {
if (response.data!!.removeDeveloperRole) {
echo("Removed role $role from developer $id")
} else {
echo("Failed to remove role $role from developer $id, do they have it?", err = true)
}
} else {
echo(response.data!!.removeDeveloperRole)
}
if (response.data!!.removeDeveloperRole) {
if (Main.standalone) exitProcess(0)
} else {
Expand Down
Loading