You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Brad Schoening (Jira)" <ji...@apache.org> on 2023/05/24 03:03:00 UTC

[jira] [Updated] (CASSANDRA-18547) Refactor cqlsh On/Off switch implementation

     [ https://issues.apache.org/jira/browse/CASSANDRA-18547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brad Schoening updated CASSANDRA-18547:
---------------------------------------
    Description: 
This change proposes to refactor the On/Off switch implemented in the class and subclass SwitchCommand and SwitchCommandWithValue of cqlshmain.py to use static methods instead of new classes.

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

 
{code:java}
self.tracing_enabled = SwitchCommand("TRACING", "Tracing").execute(self.tracing_enabled, parsed, self.printerr){code}
this can be replaced by a more familiar direct function call:
{code:java}
self.tracing_enabled = self.on_off_toggle("TRACING", "Tracing", self.tracing_enabled, parsed.get_binding('switch')){code}
 

The refactoring would rework the command output for consistency. Instead of the current:
{code:java}
> 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
{code}
replace with more succinct and consistent, using 'ON/OFF' instead of enabled/disabled and removing the redundant 'Now':
{code:java}
> tracing on
TRACING set to ON
> paging on
PAGING is already ON
> expand on
EXPAND set to ON
{code}
 

  was:
This change proposes to refactor the On/Off switch implemented in the class and subclass SwitchCommand and SwitchCommandWithValue of cqlshmain.py to use static methods instead of new classes.

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

 
{code:java}
self.tracing_enabled = SwitchCommand("TRACING", "Tracing").execute(self.tracing_enabled, parsed, self.printerr){code}
this can be replaced by a more familiar direct function call:

 

 
{code:java}
self.tracing_enabled = self.on_off_toggle("TRACING", "Tracing", self.tracing_enabled, parsed.get_binding('switch')){code}
 

 


The refactoring would rework the command output for consistency. Instead of the current:

 
{code:java}
> 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
{code}
 

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

 
{code:java}
> tracing on
TRACING set to ON
> paging on
PAGING is already ON
> expand on
EXPAND set to ON
{code}
 


> Refactor cqlsh On/Off switch implementation
> -------------------------------------------
>
>                 Key: CASSANDRA-18547
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18547
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Brad Schoening
>            Assignee: Brad Schoening
>            Priority: Normal
>
> This change proposes to refactor the On/Off switch implemented in the class and subclass SwitchCommand and SwitchCommandWithValue of cqlshmain.py to use static methods instead of new classes.
> The existing code is hard to read, including the usage, which instantiates a SwitchCommand object in-order to invoke the execute method:
>  
> {code:java}
> self.tracing_enabled = SwitchCommand("TRACING", "Tracing").execute(self.tracing_enabled, parsed, self.printerr){code}
> this can be replaced by a more familiar direct function call:
> {code:java}
> self.tracing_enabled = self.on_off_toggle("TRACING", "Tracing", self.tracing_enabled, parsed.get_binding('switch')){code}
>  
> The refactoring would rework the command output for consistency. Instead of the current:
> {code:java}
> > 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
> {code}
> replace with more succinct and consistent, using 'ON/OFF' instead of enabled/disabled and removing the redundant 'Now':
> {code:java}
> > tracing on
> TRACING set to ON
> > paging on
> PAGING is already ON
> > expand on
> EXPAND set to ON
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org