Skip to content

Add OS & shell information in 'info' command#4604

Merged
gitlost merged 5 commits intowp-cli:masterfrom
thrijith:GH-4599-v2
Jan 11, 2018
Merged

Add OS & shell information in 'info' command#4604
gitlost merged 5 commits intowp-cli:masterfrom
thrijith:GH-4599-v2

Conversation

@thrijith
Copy link
Member

@thrijith thrijith commented Jan 8, 2018

#4599 add os and shell information in wp cli info

@gitlost gitlost added the command:cli-info Related to 'cli info' command label Jan 9, 2018
@gitlost gitlost added this to the 1.5.0 milestone Jan 9, 2018
@thrijith thrijith changed the title WIP: Add OS & shell information in 'info' command Add OS & shell information in 'info' command Jan 11, 2018

$runner = WP_CLI::get_runner();

$system_os = php_uname( 's' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this block before $runner = WP_CLI::get_runner(); please?

Also might as well give as much info as possible so:

$system_os = sprintf( '%s %s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'v' ), php_uname( 'm' ) );

(only leaving out host name 'n' which people mightn't want exposed)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok @gitlost on it

$runner = WP_CLI::get_runner();

$system_os = php_uname( 's' );
$system_architecture = php_uname( 'm' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this system_architecture line would go.


$system_os = php_uname( 's' );
$system_architecture = php_uname( 'm' );
$current_shell = ( isset( $_SERVER['SHELL'] ) ) ? $_SERVER['SHELL'] : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just $shell for the variable - "current" doesn't add anything. Also could you use getenv() instead and for Windows use ComSpec if SHELL not available:

$shell = getenv( 'SHELL' );
if ( ! $shell && Utils\is_windows() ) {
	$shell = getenv( 'ComSpec' );
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @gitlost for this

if ( ! $shell && Utils\is_windows() ) {
	$shell = getenv( 'ComSpec' );
}

i didn't know about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've become a bit of a Windows guru over the last few weeks (don't use it locally or for servers)! ComSpec always returns path to cmd.exe, even on PowerShell, so isn't that great but looks a bit better anyway...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the code on Windows 7 ( installed VirtualBox just for that ) works perfectly:100:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks @thrijith !

'wp_cli_packages_dir_path' => $packages_dir,
'wp_cli_version' => WP_CLI_VERSION,
'system_os' => $system_os,
'system_architecture' => $system_architecture,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this line system_architecture goes.

'wp_cli_version' => WP_CLI_VERSION,
'system_os' => $system_os,
'system_architecture' => $system_architecture,
'current_shell' => $current_shell,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this becomes:

'shell' => $shell,

WP_CLI::line( "WP-CLI global config:\t" . $runner->global_config_path );
WP_CLI::line( "WP-CLI project config:\t" . $runner->project_config_path );
WP_CLI::line( "WP-CLI version:\t" . WP_CLI_VERSION );
WP_CLI::line( "Operating System:\t" . $system_os );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking just shorten Operating System to OS.

WP_CLI::line( "WP-CLI project config:\t" . $runner->project_config_path );
WP_CLI::line( "WP-CLI version:\t" . WP_CLI_VERSION );
WP_CLI::line( "Operating System:\t" . $system_os );
WP_CLI::line( "System Architecture:\t" . $system_architecture );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this line system_architecture goes.

WP_CLI::line( "WP-CLI version:\t" . WP_CLI_VERSION );
WP_CLI::line( "Operating System:\t" . $system_os );
WP_CLI::line( "System Architecture:\t" . $system_architecture );
WP_CLI::line( "Current Shell:\t" . $current_shell );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this line becomes:

WP_CLI::line( "Shell:\t" . $shell );

Also could you move both lines to the start, before PHP binary? Seems more logical to me and looks slightly better...

(The formatting here with tabs isn't good and we should be using a table but we'll leave it for the moment...)

@gitlost gitlost merged commit baacece into wp-cli:master Jan 11, 2018
This was referenced Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:cli-info Related to 'cli info' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants