Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make multi command and show them on help function?
Forum Updated to NodeBB v4.3 + New Features

How to make multi command and show them on help function?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 788 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kien Bui
    wrote on 2 Oct 2018, 08:47 last edited by
    #1
    $ cli --help
    Usage: root [OPTIONS] COMMAND [ARGS]...
    
    Options:
      --help  Show this message and exit.
    
    Commands:
      cmd1  Command on cli1
      cmd2  Command on cli2
    

    How to implement for this help function.

    J A 2 Replies Last reply 2 Oct 2018, 09:01
    0
    • K Kien Bui
      2 Oct 2018, 08:47
      $ cli --help
      Usage: root [OPTIONS] COMMAND [ARGS]...
      
      Options:
        --help  Show this message and exit.
      
      Commands:
        cmd1  Command on cli1
        cmd2  Command on cli2
      

      How to implement for this help function.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 2 Oct 2018, 09:01 last edited by
      #2

      @Kien-Bui What is cli1 and cli2?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Kien Bui
        2 Oct 2018, 08:47
        $ cli --help
        Usage: root [OPTIONS] COMMAND [ARGS]...
        
        Options:
          --help  Show this message and exit.
        
        Commands:
          cmd1  Command on cli1
          cmd2  Command on cli2
        

        How to implement for this help function.

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 2 Oct 2018, 09:04 last edited by aha_1980 10 Feb 2018, 09:07
        #3

        @Kien-Bui

        A good example for that is canbusutil

        This is the help output:

        Invalid number of arguments (0 given).
        
        Usage: canbusutil [options] plugin device [data]
        Sends arbitrary CAN bus frames.
        If the -l option is set, all received CAN bus frames are dumped.
        
        Options:
          -h, --help          Displays this help.
          -v, --version       Displays version information.
          -l, --listen        Start listening CAN data on device.
          -L, --list-plugins  List all available plugins.
          -t, --timestamp     Show timestamp for each received CAN bus frame.
          -i, --info          Show extra info (CAN FD flags) for each received CAN bus
                              frame.
          -d, --devices       Show available CAN bus devices for the given plugin.
        
        Arguments:
          plugin              Plugin name to use. See --list-plugins.
          device              Device to use.
          data                Data to send if -l is not specified. Format:
                              	<id>#{payload}          (CAN 2.0 data frames),
                              	<id>#Rxx                (CAN 2.0 RTR frames with xx bytes
                              data length),
                              	<id>##[flags]{payload}  (CAN FD data frames),
                              where {payload} has 0..8 (0..64 CAN FD) ASCII hex-value
                              pairs, and flags is one optional ASCII hex char for CAN FD
                              flags: 1 = Bitrate Switch, 2 = Error State Indicator
                              e.g. 1#1a2b3c
        

        Qt has to stay free or it will die.

        K 1 Reply Last reply 2 Oct 2018, 10:34
        1
        • A aha_1980
          2 Oct 2018, 09:04

          @Kien-Bui

          A good example for that is canbusutil

          This is the help output:

          Invalid number of arguments (0 given).
          
          Usage: canbusutil [options] plugin device [data]
          Sends arbitrary CAN bus frames.
          If the -l option is set, all received CAN bus frames are dumped.
          
          Options:
            -h, --help          Displays this help.
            -v, --version       Displays version information.
            -l, --listen        Start listening CAN data on device.
            -L, --list-plugins  List all available plugins.
            -t, --timestamp     Show timestamp for each received CAN bus frame.
            -i, --info          Show extra info (CAN FD flags) for each received CAN bus
                                frame.
            -d, --devices       Show available CAN bus devices for the given plugin.
          
          Arguments:
            plugin              Plugin name to use. See --list-plugins.
            device              Device to use.
            data                Data to send if -l is not specified. Format:
                                	<id>#{payload}          (CAN 2.0 data frames),
                                	<id>#Rxx                (CAN 2.0 RTR frames with xx bytes
                                data length),
                                	<id>##[flags]{payload}  (CAN FD data frames),
                                where {payload} has 0..8 (0..64 CAN FD) ASCII hex-value
                                pairs, and flags is one optional ASCII hex char for CAN FD
                                flags: 1 = Bitrate Switch, 2 = Error State Indicator
                                e.g. 1#1a2b3c
          
          K Offline
          K Offline
          Kien Bui
          wrote on 2 Oct 2018, 10:34 last edited by
          #4

          @aha_1980
          But in Usage part

          Usage: canbusutil [options] plugin device [data]
          

          plugin, device: They can't both exist on a command

          A 1 Reply Last reply 2 Oct 2018, 10:58
          0
          • K Kien Bui
            2 Oct 2018, 10:34

            @aha_1980
            But in Usage part

            Usage: canbusutil [options] plugin device [data]
            

            plugin, device: They can't both exist on a command

            A Offline
            A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on 2 Oct 2018, 10:58 last edited by
            #5

            @Kien-Bui

            Do you want to have something like git?

            git pull [options]
            git rebase branch [options]
            git checkout branch [options]
            git cherry-pick hast [options]
            

            ?

            I think you have to set up different QCommandLineParsers for that, because the help and the options change depending on the sub-command (pull, rebase, checkout, cherry-pick).

            So you would have to parse the sub-command (positional argument) and then parse the rest of the command line to see if all arguments and options are correct.

            Qt has to stay free or it will die.

            1 Reply Last reply
            0

            1/5

            2 Oct 2018, 08:47

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved