Symfony Console Output - symfony

I am writing my first symfony console apps and I would like to ask a question regarding the console outputs.
When I run a new CLI app in the console like: ./testapp then I get the following output:
Usage:
command [options] [arguments]
Options:
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question
Available commands:
help Displays help for a command
list Lists commands
Is there a way to remove the display of this content? I want only the "Available Commands" to be visible. And is it possible to create my own groups in this display?

As of Symfony 2.5, you can change the default command (the command that's executed when no command name was specified). See for more information: http://symfony.com/doc/current/components/console/changing_default_command.html
The Console component will always run the ListCommand when no command name is passed. In order to change the default command you just need to pass the command name to the setDefaultCommand method.

(Symfony Console 4.1)
It's possible to remove the default options:
$options = $app->getDefinition()->getOptions();
unset($options['ansi']);
unset($options['no-interaction']);
unset($options['verbose']);
unset($options['help']);
unset($options['quiet']);
unset($options['version']);
unset($options['no-ansi']);
$app->getDefinition()->setOptions($options);
or just:
$app->getDefinition()->setOptions();
Options group will not show in the list command.
Although I don't know if this has any undesirable side effect.

Related

responding yes to terminal prompt via system2() in R

tl;dr: How can I invoke the system command y | conda create --name gee_interface from an R console, e.g. via system2()? I'm comfortable enough with system2('conda', c('create', '--name', 'gee_interface')), but I don't know how to handle piping in the 'y' via system2().
Details
I am trying to use an R console to run the bash command conda create --name gee_interface (OSX Mojave with Anaconda installed).
In terminal, that command executes just fine, but prompts me to answer with Proceed ([y]/n)? (I answer 'y' and everything works smoothly).
In R, I run
Sys.setenv(PATH = paste(c("/Applications/anaconda3/bin", Sys.getenv("PATH")), collapse = .Platform$path.sep)) # ensures that system2() finds conda
system2('conda', c('create', '--name', 'gee_interface')) # This is the key line for the purposes of this question
When running the second line [i.e. system2('conda', c('create', '--name', 'gee_interface'))], the process never finishes, but quickly falls to zero CPU usage. Presumably the system is waiting for my response to the prompt, but I don't know how to provide it. How does one do this via an R script? Note also that in my particular case, the number of times that I need to respond 'y' is variable, depending on whether an environment of the name gee_interface already exists or not.
The fix to your first problem is to tell conda not to ask for confirmation using -y:
system2('conda', c('create', '--name', 'gee_interface', '-y'))
As to the second part (variable times that your input is required), I'm guessing it's to overwrite the environment if it exists? In that case, you could check for its existence first with conda info --envs, and run conda remove --name gee_interface --all if necessary before creating it.
See:
https://docs.conda.io/projects/conda/en/latest/commands/create.html
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#removing-an-environment
You could also try your system2 call, with the argument input = "y", but that doesn't fix your second problem of needing to affirm multiple times.
See: Invoke a system command and pipe a variable as an argument

Running Nvim-R via PuTTy: setting up r_term_cdm

I would like to run Nvim-R on a remote machine via putty when I try to open a *.R file the remote machine returns an error message:
Please set the variable g:R_term_cmd in your vimrc. Read the plugin
documentation ...
According to the documentation, the R_term_cmd should be used in the following manner:
If |R_in_buffer| = 0 and the X Window System is running and tmux is
installed, then R will run in an external terminal emulator. The
plugin uses the first terminal emulator that it finds in the following
list:
1. gnome-terminal,
2. konsole,
3. xfce4-terminal,
4. Eterm,
5. (u)rxvt,
6. aterm,
7. roxterm,
8. terminator,
9. lxterminal
10. xterm.
If Vim does not select your favorite terminal emulator, you may define
it in your vimrc by setting the variable R_term, as shown below:
let R_term = "xterm"
If your terminal emulator is not listed above, or if you are not satisfied with the way your terminal emulator
is called by the plugin, you may define in your vimrc the variable
R_term_cmd, as in the examples below:
let R_term_cmd = "xterm -title R -e"
let R_term_cmd = "xfce4-terminal --icon=/path/to/icons/R.png --title=R -x"
However, this variable does not appear to be utilised by the sample configuration files available through the Vim-R-Tmux: An Integrated Working Environment for R. Furthermore, the settings in vimrc:
" start R with F2 key
map <F2> <Plug>RStart
imap <F2> <Plug>RStart
vmap <F2> <Plug>RStart
" send selection to R with space bar
vmap <Space> <Plug>RDSendSelection
" send line to R with space bar
nmap <Space> <Plug>RDSendLine
<LocalLeader> settings
The suggested <LocalLeader> settings not appear to work as pressing F2 does not launch connected R session.
Software versions
tmux 2.3
VIM - Vi IMproved 8.0
You have two options
Use Tmux, which you apparently are
This way, Nvim-R can actually use a tmux pane to start an R console.
Please refer to section 9.21 Integration with Tmux in the documentation.
You need to put the following in your vimrc:
let R_in_buffer = 0
let R_applescript = 0
let R_tmux_split = 1
Or just use NeoVim
NeoVim has a builtin terminal, which actually just works with the Nvim-R plugin.

set verbose in command Symfony3

I can set verbosity of my command with
php bin/console mycommand:command -vvv
How can i Set the same value with --verbose? 2.3 symfony
php bin/console mycommand:command --verbose=3
I have this error
[Symfony\Component\Console\Exception\RuntimeException]
The "--verbose" option does not accept a value.
With helper I can see this option
-v|vv|vvv, --verbose Increase the verbosity of
messages: 1 for normal output, 2 for more verbose output and 3 for
debug
I digged into the code and it seems to be a bug in the console component (I may be wrong, but I'm pretty sure it actually is a bug). The --verbose option is defined with a value of InputOption::VALUE_NONE, indicating it is not allowing any values.
I created a bug report here: https://github.com/symfony/symfony/issues/18546
It is a bug in the documentation of symfony and is not supported. Use -v, -vv or -vvv respectively (see the answer in my bug report).

Enter doesn't work when interactive command is launched in shell

After some actions in term enter stops working in with interactive commands in shell - I am still able to launch a command but if the command requires additional inputs line break is inserted at '^M'.
Example:
$ git add -p .
diff --git a/app/models/coupon.rb b/app/models/coupon.rb
index 39df1f3..736ea62 100644
--- a/app/models/coupon.rb
+++ b/app/models/coupon.rb
## -3,6 +3,7 ## class Coupon < ActiveRecord::Base
COUPON_PRECREATE_EXPIRATION_BUFFER = 5.days
COUPON_PRECREATE_COUNT = 15
+ include CommonNamedScopes
belongs_to :coupon_list
#belongs_to :couponable, :polymorphic => true
Stage this hunk [y,n,q,a,d,/,e,?]? y^M
(same problem can be achived when using cat for example) so it has no relation to git.
Can someone advice why this is happening?
iTerm2 Build 1.0.0.20120724
zsh 5.0.0 (x86_64-apple-darwin11.4.2)
That generally is because a program changed the state of the terminal, but did not change it back.
Try running the reset command, and see if that fixes things.
Since you're using zsh, you could also use ttyctl -f to have zsh automatically reset terminal settings after commands are run. But don't use that before resetting the terminal first or zsh will freeze the settings in the broken state.

Pydev Eclipse console does not support curses.setupterm

I cannot run a script in Eclipse that works perfectly in a terminal.
It seems that Eclipse console cannot support some functions. I am looking for a workaround to be able to debug the script using Pydev.
Is it possible to set PyDev to use for example /usr/bin/gnome-terminal instead of the Eclipse native console ?
Otherwise it there a way to define a wrapper as a python interpreter for PyDev that will launch an terminal external to Eclipse (I've tried but failed on that).
Thank you
Nga
Right now, curses-based apps really don't run well inside Eclipse/PyDev, so, you must really launch it externally. To debug you can use the remote debugger: http://pydev.org/manual_adv_remote_debugger.html
If you use Aptana Studio, there's a terminal view which should emulate a terminal better... try running python (i.e.: running your program) from inside that view. If it does work properly there, maybe I could check a way to better integrate there and launch directly in that view.
Thank you for your reply. I have finally defined kind of a wrapper as a bash script calling python in a xterm. Pydev is checking some configuration by calling eclipse/plugins/org.python.pydev_2.4.0.2012020116/PySrc/interpreterInfo.py so the script first echo the format expected by PyDev. here is the script "
#!/bin/bash
# dummy return for Eclipse Pydev - respect interpreter info format
echo "EXECUTABLE:/home/user/python_custom/python_xterm|
|/home/user/eclipse/plugins/org.python.pydev_2.4.0.2012020116/PySrc
|/usr/lib/python2.5
|/usr/lib/python2.5/plat-linux2
|/usr/lib/python2.5/lib-tk
|/usr/lib/python2.5/lib-dynload
|/usr/local/lib/python2.5/site-packages
|/usr/lib/python2.5/site-packages
|/usr/lib/python2.5/site-packages/Numeric
|/usr/lib/python2.5/site-packages/PIL
|/usr/lib/python2.5/site-packages/gst-0.10
|/var/lib/python-support/python2.5
|/usr/lib/python2.5/site-packages/gtk-2.0
|/var/lib/python-support/python2.5/gtk-2.0
|/var/lib/python-support/python2.5/HTMLgen
|/var/lib/python-support/python2.5/pyinotify
|/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode
|/usr/lib/site-python
#
$
|__builtin__
|__main__
|_ast
|_codecs
|_sre
|_symtable
|_types
|errno
|exceptions
|gc
|imp
|marshal
|posix
|pwd
|signal
|sys
|thread
|xxsubtype
|zipimport
"
# activate scrollbar -sb with 6000 lines
# allow logging -l with filename log_$NOW
xterm -g 150x100+0+0 -sb -sl 6000 -si -hold -e "python $*"
that does the job, and I can use Pydev and its debugger

Resources