mono / sdb

A command line client for the Mono soft debugger.
https://www.mono-project.com
MIT License
116 stars 44 forks source link

I want to use addCommand (^_^)/ #47

Closed callmekohei closed 6 years ago

callmekohei commented 6 years ago

Hello! I'm callmekohei!

Problem

I can not use addCommand.

Expected behavior

I can use addCommand

Like this

[<Sealed; Command>]
type MyCommand() =
    inherit Command()
    override __.Names   = [|"mycmd"|]
    override __.Summary = "aaa bbb ccc"
    override __.Syntax  = "ddd eee fff"
    override __.Help    = "Help Help Help"
    override __.Process(args) =

        AddCommand<StepOverCommand>()  // <---- step over

        // run my code after running step over
        Log.Info("hello world")

work around

(sdb) do , step over , mycmd

reason

  1. Take time to input when we use sdb on command-line.

  2. Flickering screen

like this

untitled

alexrp commented 6 years ago

The correct way to do this is in the MyCommand constructor, like here for ThreadCommand for example: https://github.com/mono/sdb/blob/master/src/Commands/ThreadCommand.cs#L267

callmekohei commented 6 years ago

Hello again! I'm callmekohei!

So may I have question?

I write code following:

namespace Mono.Debugger.Client.Commands

[<Sealed; Command>]
type HelloWorld() =

    inherit Command()

    override __.Names   = [|"bbbCmd"|]
    override __.Summary = "aaa bbb ccc"
    override __.Syntax  = "ddd eee fff"
    override __.Help    = "Help Help Help"
    override __.Process(args) =
        Log.Info("hello world from bbbCmd")

[<Sealed; Command>]
type MyCommand() =

    inherit MultiCommand()

    override this.Names   = [|"aaaCmd"|]
    override this.Summary = "aaaaaaaaaaa"
    override this.Syntax  = "bbbbbbbbbbb"
    override this.Help    = "ccccccccccc"

    member public this.MyCommand() =
        this.AddCommand<HelloWorld>()
        this.Forward<HelloWorld>()
        Log.Info("hello world")

result

(sdb) help

  aaaCmd
    aaaaaaaaaaa

(sdb) help aaaCmd

  bbbbbbbbbbb

ccccccccccc

(sdb) aaaCmd
No 'aaaCmd' sub-command specified     <---- wooops! (^_^;;;

Please tell me anything if you have nice idea!

So sorry for F# code instead of C# code. (^_^;;

callmekohei commented 6 years ago

Hello again! I'm callmekohei!

So, I can just do it !

Thank you for your advice!

like this

namespace Mono.Debugger.Client.Commands
open Mono.Debugger.Client
open Mono.Debugging.Client

type helloworld() =

    inherit command()

    override __.names   = [|"bbbcmd"|]
    override __.summary = "aaa bbb ccc"
    override __.syntax  = "ddd eee fff"
    override __.help    = "help help help"
    override __.process(args) =
        log.info("hello world from bbbcmd")

[<Sealed; Command>]
type MyCommand() =
    inherit MultiCommand()

    do base.AddCommand<HelloWorld>()

    override this.Names   = [|"aaaCmd"|]
    override this.Summary = "aaaaaaaaaaa"
    override this.Syntax  = "bbbbbbbbbbb"
    override this.Help    = "ccccccccccc"

screen shot 2018-01-14 at 16 07 48

callmekohei commented 6 years ago

And thank you for Japanese F#ers!

https://gitter.im/fsugjp/public?at=5a5a912fba39a53f1a10fd00