Skip to content

simplify cli #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2021
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
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ jobs:
- name: "[CLI] Remove developer"
run: ./build/graal/spp-cli -v admin remove-developer test
- name: "[CLI] Add live breakpoint"
run: ./build/graal/spp-cli -v developer add-live-breakpoint -h 100 spp.example.webapp.model.User 48
run: ./build/graal/spp-cli -v add-breakpoint -h 100 spp.example.webapp.model.User 48
- name: "[CLI] Add live log"
run: ./build/graal/spp-cli -v developer add-live-log -h 100 spp.example.webapp.model.User 48 test-message
run: ./build/graal/spp-cli -v add-log -h 100 spp.example.webapp.model.User 48 test-message
- name: "[CLI] Get live instruments"
run: ./build/graal/spp-cli -v developer get-live-instruments
run: ./build/graal/spp-cli -v get-instruments
- name: "[CLI] Get live breakpoints"
run: ./build/graal/spp-cli -v developer get-live-breakpoints
run: ./build/graal/spp-cli -v get-breakpoints
- name: "[CLI] Get live logs"
run: ./build/graal/spp-cli -v developer get-live-logs
run: ./build/graal/spp-cli -v get-logs
- name: "[CLI] Remove live instruments"
run: ./build/graal/spp-cli -v developer remove-live-instruments spp.example.webapp.model.User 48
run: ./build/graal/spp-cli -v remove-instruments spp.example.webapp.model.User 48

- name: Zip spp-cli
run: zip spp-cli-linux64.zip -j build/graal/spp-cli
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This project provides a command-line interface client to the [Source++](https://
<summary>Command</summary>

```sh
./spp-cli developer add-live-breakpoint com.company.Webapp 42
./spp-cli add-breakpoint com.company.Webapp 42
```
</details>

Expand Down
41 changes: 18 additions & 23 deletions src/main/kotlin/spp/cli/Main.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package spp.cli

import com.github.ajalt.clikt.core.subcommands
import spp.cli.commands.PlatformCLI
import spp.cli.commands.Version
import spp.cli.commands.admin.Admin
import spp.cli.commands.admin.Reset
import spp.cli.commands.admin.access.*
import spp.cli.commands.admin.developer.AddDeveloper
import spp.cli.commands.admin.developer.GetDevelopers
Expand All @@ -13,11 +14,7 @@ import spp.cli.commands.admin.permission.GetDeveloperPermissions
import spp.cli.commands.admin.permission.GetRolePermissions
import spp.cli.commands.admin.permission.RemoveRolePermission
import spp.cli.commands.admin.role.*
import spp.cli.commands.developer.Developer
import spp.cli.commands.developer.instrument.*
import spp.cli.commands.system.System
import spp.cli.commands.system.etc.Reset
import spp.cli.commands.system.etc.Version
import spp.cli.commands.instrument.*

object Main {

Expand All @@ -28,11 +25,7 @@ object Main {
fun main(args: Array<String>) {
Main.args = args
PlatformCLI.subcommands(
System().subcommands(
//etc
Reset(),
Version()
),
//admin
Admin().subcommands(
//role
AddRole(),
Expand All @@ -58,19 +51,21 @@ object Main {
GetDeveloperAccessPermissions(),
GetRoleAccessPermissions(),
RemoveAccessPermission(),
RemoveRoleAccessPermission()
RemoveRoleAccessPermission(),
//etc
Reset()
),
Developer().subcommands(
//instrument
AddLiveBreakpoint(),
AddLiveLog(),
GetLiveBreakpoints(),
GetLiveInstruments(),
GetLiveLogs(),
RemoveLiveInstrument(),
RemoveLiveInstruments(),
ClearLiveInstruments()
)
//instrument
AddBreakpoint(),
AddLog(),
GetBreakpoints(),
GetInstruments(),
GetLogs(),
RemoveInstrument(),
RemoveInstruments(),
ClearInstruments(),
//etc
Version()
).main(args)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package spp.cli.commands
package spp.cli

import com.apollographql.apollo.ApolloClient
import com.auth0.jwt.JWT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package spp.cli.commands.system.etc
package spp.cli.commands

import com.github.ajalt.clikt.core.CliktCommand
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package spp.cli.commands.system.etc
package spp.cli.commands.admin

import com.apollographql.apollo.coroutines.await
import com.apollographql.apollo.exception.ApolloException
import com.github.ajalt.clikt.core.CliktCommand
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import system.ResetMutation
import kotlin.system.exitProcess

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.github.ajalt.clikt.parameters.types.enum
import io.vertx.core.json.JsonObject
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.PlatformCLI
import spp.cli.util.JsonCleaner.cleanJson
import type.AccessType
import kotlin.system.exitProcess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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.commands.PlatformCLI
import spp.cli.PlatformCLI
import kotlin.system.exitProcess

class AddRoleAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import io.vertx.core.json.JsonObject
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.PlatformCLI
import spp.cli.util.JsonCleaner.cleanJson
import kotlin.system.exitProcess

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import io.vertx.core.json.JsonObject
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.PlatformCLI
import spp.cli.util.JsonCleaner.cleanJson
import kotlin.system.exitProcess

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import io.vertx.core.json.JsonObject
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.PlatformCLI
import spp.cli.util.JsonCleaner.cleanJson
import kotlin.system.exitProcess

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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.commands.PlatformCLI
import spp.cli.PlatformCLI
import kotlin.system.exitProcess

class RemoveAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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.commands.PlatformCLI
import spp.cli.PlatformCLI
import kotlin.system.exitProcess

class RemoveRoleAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import developer.AddDeveloperMutation
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class AddDeveloper : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import com.github.ajalt.clikt.core.CliktCommand
import developer.GetDevelopersQuery
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class GetDevelopers : CliktCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import developer.RefreshDeveloperTokenMutation
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class RefreshDeveloperToken : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import developer.RemoveDeveloperMutation
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class RemoveDeveloper : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import com.github.ajalt.clikt.parameters.types.enum
import kotlinx.coroutines.runBlocking
import permission.AddRolePermissionMutation
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import type.RolePermission
import kotlin.system.exitProcess

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import permission.GetDeveloperPermissionsQuery
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class GetDeveloperPermissions : CliktCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import permission.GetRolePermissionsQuery
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class GetRolePermissions : CliktCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import permission.RemoveRolePermissionMutation
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class RemoveRolePermission : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import role.AddDeveloperRoleMutation
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class AddDeveloperRole : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/spp/cli/commands/admin/role/AddRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import role.AddRoleMutation
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class AddRole : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import role.GetDeveloperRolesQuery
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class GetDeveloperRoles : CliktCommand() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/spp/cli/commands/admin/role/GetRoles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import com.github.ajalt.clikt.core.CliktCommand
import kotlinx.coroutines.runBlocking
import role.GetRolesQuery
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class GetRoles : CliktCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import role.RemoveDeveloperRoleMutation
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class RemoveDeveloperRole : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/spp/cli/commands/admin/role/RemoveRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import kotlinx.coroutines.runBlocking
import role.RemoveRoleMutation
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import kotlin.system.exitProcess

class RemoveRole : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
7 changes: 0 additions & 7 deletions src/main/kotlin/spp/cli/commands/developer/Developer.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package spp.cli.commands.developer.instrument
package spp.cli.commands.instrument

import com.apollographql.apollo.api.ScalarTypeAdapters
import com.apollographql.apollo.api.internal.SimpleResponseWriter
Expand All @@ -15,16 +15,16 @@ import instrument.AddLiveBreakpointMutation
import io.vertx.core.json.JsonObject
import kotlinx.coroutines.runBlocking
import spp.cli.Main
import spp.cli.commands.PlatformCLI
import spp.cli.commands.PlatformCLI.apolloClient
import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.apolloClient
import spp.cli.util.JsonCleaner.cleanJson
import type.InstrumentThrottleInput
import type.LiveBreakpointInput
import type.LiveSourceLocationInput
import type.ThrottleStep
import kotlin.system.exitProcess

class AddLiveBreakpoint : CliktCommand() {
class AddBreakpoint : CliktCommand() {

val source by argument(help = "Qualified class name")
val line by argument(help = "Line number").int()
Expand Down
Loading