I started paying around with Crystal lang, I want to use OptionParser to show a help text, however -h will be interpred by Crystal instead of OptionParser
I am using the example from https://crystal-lang.org/api/0.18.7/OptionParser.html
and calling the app myAppl with:
crystal src/myAppl.cr --help
This shows Crystal help.
Now, if I compile the app then it shows the help text I wrote OptionParser
What I am doing wrong?
Have a look at the first line of that help output:
Usage: crystal run [options] [programfile] [--] [arguments]
That -- is what allows you to force an argument to be passed to the compiled program rather than being used by the compiler. So following your example:
crystal src/myApp1.cr -- --help
Of course if you compile your program you can just pass it directly to the resulting binary:
crystal build src/myApp1.cr
./myApp1 --help
Related
I'm a beginner. I started exploring Pythran and Transonic a few days back. I learned that Pythran generates a C++ file from the Python input file. I want to read those C++ generated files in the backend.
Do anyone of you have any idea about accessing files generated in the backend?
I'm implementing Pythran using Transonic's support.
Thanks!
Have you tried running pythran with the --help option?
...
optional arguments:
-h, --help show this help message and exit
-o OUTPUT_FILE path to generated file. Honors %{ext}.
-P only run the high-level optimizer, do not compile
-E only run the translator, do not compile
...
So, the answer is: use the -E option
pythran my_python_file.py -E
Since everything is 32-bit, I used :set makeprg=mingw32-make, and then tried compiling via :!make, which gave the following error message:
'make' is not recognized as an internal or external command, operable program or batch file.
shell returned 1
I tried the basic "Goodbye World" stuff:
#include <iostream>
int main() {
std::cout << "Goodbye World";
return 0;
}
What am I doing wrong? Other than being a noob.
:!make doesn't run 'makeprg'. It runs make. Since you are specifically trying to run mingw32-make.exe, presumably you don't have an executable named make.exe. (See :help :!)
:make runs 'makeprg'. (See :help :make, :help 'makeprg')
my goal is to see the "Goodbye World" either in console or terminal or any observable way. Would this require additional tinkering to the _vimrc file?
You would rather want to do it by tinkering with your makefile. Any arguments to :make will be passed to 'makeprg'. If you defined targets clean (to remove the Make artefacts) or run (to execute the product of your Make), you will be able to write :mak clean or :mak run in Vim to run those targets. Obviously, you can create your own commands and/or mappings to make those :make commands faster.
Note (and I completely overlooked this myself, silly me) that when you run a simple code, such as the one above, that does not need extensive file managements and Makefiles, all you need to go is :!gcc % for C and :!g++ % for C++. I believe (and I may be wrong, but this is a simple observation) that in Vim, :! indicates the following commands are to be executed in the system Command Prompt, and gcc/g++ is the command to invoke the GNU Compiler for C and C++ respectively. Finally, % is used to indicate the current filename, with all extensions intact. This is extremely useful in cases of keymapping, as I have done via the following:
nnoremap <F5> :!g++ %<CR>|"Press Func.5 to Compile via GNU Comp.
I have been following the "Making an Emotion-Aware Music Player" tutorial and everything was works fine until running the main program in update.
I searched for "argparse " in tutorials and found nothing about this method.
I have a very little knowledge about python so that could anyone please explain me how run the main program in update mode and where should type the following code.
source page: Making an Emotion-Aware Music Player
Once the file is downloaded, call the main program in “update mode” like this:
~
#To activate update mode, pass the --update flag
python <filename.py> --update
#To get help, use the -h or --help flag
python <filename.py> -h
python <filename.py> --help
When I ran the above code in Command prompt it gave me a error, which says there is no XML file. But as for the main program it should create XML if there wasn't.
I'm using Visual studio 2015 with python 2.7
I want to give ocamldebug a try. How can I run a program in it with a set of arguments? I can't find anything related in the reference documentation.[1]
In GDB, I would enter run arg1...argn. Unfortunately it doesn't seem to work in ocamldebug.
$ ocamldebug server.byte
OCaml Debugger version 4.04.0
(ocd) run -i 127.0.0.1 -p 8080
Syntax error.
(ocd)
Entering help run doesn't give much information:
(ocd) help run
run: run the program from current position.
https://caml.inria.fr/pub/docs/manual-ocaml/debugger.html
From docs:
ocamldebug [options] program [arguments]
The arguments following program are optional, and are passed as
command-line arguments to the program being debugged. (See also the
set arguments command.)
In debugger, you can use set arguments -i 127.0.0.1 -p 8080 command.
I have found several conflicting answers over this topic. This blog post requires libuwind, but that doesn't work on Mac OS X. I included #include <google/profiler.h> in my code, however my compiler (g++) could not find the library. I installed gperftools via homebrew. In addition, I found this stackoverflow question showing this:
Then I ran pprof to generate the output:
[hidden ~]$ pprof --text ./a.out cpu.profile
Using local file ./a.out.
Using local file cpu.profile.
Removing __sigtramp from all stack traces.
Total: 282 samples
107 37.9% 37.9% 107 37.9% 0x000000010d72229e
16 5.7% 43.6% 16 5.7% 0x000000010d721a5f
12 4.3% 47.9% 12 4.3% 0x000000010d721de8
...
Running that command (without any of the prior steps) gets me this:
[hidden]$ pprof --text ./a.out cpu.profile
Using remote profile at ./a.out.
Failed to get the number of symbols from http://cpu.profile/pprof/symbol
Why does it try to access an internet site on my machine and a local file on his/hers?
Attempting to link lib profiler as a dry run with g++ gets me:
[hidden]$ g++ -l libprofiler
ld: library not found for -llibprofiler
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have looked at the man pages, the help option text, the official online guide, blog posts, and many other sources.
I am so confused right now. Can someone help me use gperftools?
The result of my conversation with #osgx was this script. I tried to clean it up a bit. It likely contains quite a few unnecessary options too.
The blog post https://dudefrommangalore.wordpress.com/2012/02/09/profiling-c-code-using-google-performance-tools/ "Profiling C++ code using Google Performance Tools" 2012 by dudefrommangalore missed the essential step.
You should link your program (which you want to be profiled) with cpu profiler library of gperftools library.
Check official manual: http://goog-perftools.sourceforge.net/doc/cpu_profiler.html, part "Linking in the Library"
add -lprofiler to the link-time step for your executable. (It's also probably possible to add in the profiler at run-time using LD_PRELOAD, but this isn't necessarily recommended.)
Second step is to collect the profile, run the code with profiling enabled. In linux world it was done by setting controlling environment variable CPUPROFILE before running:
CPUPROFILE=name_of_profile ./program_to_be_profiled
Third step is to use pprof (google-pprof in ubuntu world). Check that there is not-empty name_of_profile profile file generated; it there is no such file, pprof will try to do remote profile fetch (you see output of such try).
pprof ./program_to_be_profiled name_of_profile
First you need to run your program with profiling enabled.
This is usually first linking your program with libprofiler and then running it with CPUPROFILE=cpu.profile.
I.e.
$ CPUPROFILE=cpu.profile my_program
I think that later step is what you have been missing.
The program will create this cpu.profile file when it exits. And then you can use pprof (preferably from github.com/google/pprof) on it to visualize/analyze.