Skip to content

Deprecated CmdResult helper class and promoted CommandResult #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2018

Conversation

tleonhardt
Copy link
Member

These classes are subtly different, particularly in terms of their truthiness.

CmdResult

  • attributes: out, err, war
  • truthy: if err is falsy

CommandResult

  • attributes: stdout, stderr, data
  • truthy: if err is falsy AND data is not None

So CmdResult was oriented to provide essentially info, error, and warning messages to the user (typically as stirngs), whereas CommandResult is geared towards providing info and error messages to the user as strings in addition to data to the user in a command-specific format which is arbitrary other than it should never be None if the command succeeds.

This closes #449

These classes are subtly different, particularly in terms of their truthiness.

CmdResult
- attributes:  out, err, war
- truthy:  if err is falsy

CommandResult
- attributes:  stdout, stderr, data
- truthy:  if err is falsy AND data is not None

So CmdResult was oriented to provide essentially info, error, and warning messages to the user (typically as stirngs), whereas CommandResult is geared towards providing info and error messages to the user as strings in addition to data to the user in a command-specific format which is arbitrary other than it should never be None if the command succeeds.
@tleonhardt tleonhardt added this to the 0.9.2 milestone Jun 23, 2018
@tleonhardt tleonhardt self-assigned this Jun 23, 2018
@codecov
Copy link

codecov bot commented Jun 23, 2018

Codecov Report

Merging #451 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #451      +/-   ##
==========================================
- Coverage   90.22%   90.18%   -0.04%     
==========================================
  Files          10       10              
  Lines        2741     2741              
==========================================
- Hits         2473     2472       -1     
- Misses        268      269       +1
Impacted Files Coverage Δ
cmd2/cmd2.py 90.43% <ø> (-0.07%) ⬇️
cmd2/pyscript_bridge.py 96.55% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40dc455...eb749b5. Read the comment docs.

@tleonhardt
Copy link
Member Author

I would appreciate any feedback and opinions. These two classes are slightly different, so it isn't exactly like the new one is clearly 100% better than the now deprecated one in all cases, though I do think it is better in general. But they exist primarily in helper roles and the old one isn't used within cmd2 itself, so it kind of feels awkward to leave it around.

As long as everyone thinks this is a good path forward I'm happy with the changes.

@tleonhardt
Copy link
Member Author

@kmvanbrunt @kotfu @anselor
Any opinions on this PR?

@kmvanbrunt
Copy link
Member

@tleonhardt
I'm OK merging it.

@tleonhardt tleonhardt merged commit 63aa28c into master Jun 26, 2018
@tleonhardt tleonhardt deleted the command_result branch June 26, 2018 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace legacy CmdResult class with new CommandResult class
2 participants