Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-18547

Refactor cqlsh On/Off switch implementation and make the output consistent

    XMLWordPrintableJSON

Details

    Description

      This change refactors the On/Off switch implemented in the class SwitchCommand and subclass  SwitchCommandWithValue of cqlshmain.py to use an Enum with static methods instead of custom classes.

      The body of on_off_switch + enum definition requires just 15 lines of code vs 33 in SwitchCommand.

      The existing code is hard to read, including the usage in the code, which instantiates a SwitchCommand object in-order to invoke the execute method:

       

      self.tracing_enabled = SwitchCommand("TRACING", "Tracing").execute(self.tracing_enabled, parsed, self.printerr)

      this can be replaced by a more familiar direct function call:

      self.tracing_enabled = self.on_off_toggle("TRACING", "Tracing", self.tracing_enabled, parsed.get_binding('switch'))

       

      The refactoring also updates the command output for consistency. Instead of the current:

      > tracing on
      Now Tracing is enabled
      > paging on
      Query paging is already enabled. Use PAGING OFF to disable.
      > expand on
      Now Expanded output is enabled
      

      replace with more succinct and consistent, using 'ON/OFF' instead of enabled/disabled and removing the redundant 'Now':

      > tracing on
      TRACING set to ON
      > paging on
      PAGING is already ON
      > expand on
      EXPAND set to ON
      

       

      Attachments

        Issue Links

          Activity

            People

              bschoeni Brad Schoening
              bschoeni Brad Schoening
              Brad Schoening
              Brandon Williams, Stefan Miklosovic
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m