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?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 918 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 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.

    jsulmJ aha_1980A 2 Replies Last reply
    0
    • K Kien Bui
      $ 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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
        $ 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.

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by aha_1980
        #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
        1
        • aha_1980A aha_1980

          @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 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

          aha_1980A 1 Reply Last reply
          0
          • K Kien Bui

            @aha_1980
            But in Usage part

            Usage: canbusutil [options] plugin device [data]
            

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

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on 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

            • Login

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