command-line-interface

Are there standards for Linux command line switches and arguments?

两盒软妹~` 提交于 2019-11-26 15:17:00
问题 This is more about the invocation of a program, than any language or parser (though I'm sure choice of parser library can depend on this). See, I've used a lot of Linux command-line utilities. And there are some obvious patterns; '-' precedes a single letter for short options, multiple options that don't take arguments can be combined, '--' precedes long versions of options, and so on. However, in some cases, capitalization is used to invert an option. So, '-d' might mean to run as a daemon,

How to open Atom editor from command line in OS X?

血红的双手。 提交于 2019-11-26 14:58:19
问题 I have the Atom editor and was wondering how you can open a file or folder from the terminal in Atom. I am using a Mac. I am looking for a way to do this: atom . (opens folder) atom file.js (opens file) atom (opens editor) Is this possible and how do I set it up? 回答1: When Atom installs it automatically creates a symlink in your /usr/local/bin. However in case it hasn't, you can create it yourself on your Mac ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom Now

Can't get argparse to read quoted string with dashes in it?

大憨熊 提交于 2019-11-26 14:36:56
Is there a way to make argparse recognize anything between two quotes as a single argument? It seems to keep seeing the dashes and assuming that it's the start of a new option I have something like: mainparser = argparse.ArgumentParser() subparsers = mainparser.add_subparsers(dest='subcommand') parser = subparsers.add_parser('queue') parser.add_argument('-env', '--extraEnvVars', type=str, help='String of extra arguments to be passed to model.') ...other arguments added to parser... But when I run: python Application.py queue -env "-s WHATEVER -e COOL STUFF" It gives me: Application.py queue:

Set max_execution_time in PHP CLI

那年仲夏 提交于 2019-11-26 13:09:34
问题 I know that PHP CLI is usually used because of none time limits and primary because it is not using Apache threads/processes. But is there any way how to explicitly set the max_execution_time for some scripts which i don\'t want to have the freedom of \"unlimited time\" and just want to keep those script under control? If you think this question may be better answered on superuser.com and have permission to move it, do it. :) Edit : I\'ve been Googling a bit and found the right parameter: php

Why does my C# array lose type sign information when cast to object?

混江龙づ霸主 提交于 2019-11-26 13:01:45
问题 Investigating a bug, I discovered it was due to this weirdness in c#: sbyte[] foo = new sbyte[10]; object bar = foo; Console.WriteLine(\"{0} {1} {2} {3}\", foo is sbyte[], foo is byte[], bar is sbyte[], bar is byte[]); The output is \"True False True True\", while I would have expected \" bar is byte[] \" to return False. Apparently bar is both a byte[] and an sbyte[] ? The same happens for other signed/unsigned types like Int32[] vs UInt32[] , but not for say Int32[] vs Int64[] . Can anyone

call up an EDITOR (vim) from a python script

若如初见. 提交于 2019-11-26 12:55:20
问题 I want to call up an editor in a python script to solicit input from the user, much like crontab e or git commit does. Here\'s a snippet from what I have running so far. (In the future, I might use $EDITOR instead of vim so that folks can customize to their liking.) tmp_file = \'/tmp/up.\'+\'\'.join(random.choice(string.ascii_uppercase + string.digits) for x in range(6)) edit_call = [ \"vim\",tmp_file] edit = subprocess.Popen(edit_call,stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True

How to cartoon-ify an image programmatically?

吃可爱长大的小学妹 提交于 2019-11-26 12:19:56
问题 My app works with photos and videos of people, which I want to cartoonify. So I need an algorithm to do it manually (we use c++/Qt for our product, which has image manipulation classes) or perhaps some CLI program that will do it for me that I can call and use from our own app. 回答1: Here's some algorithms to play with: Median or repeated box blur filter to obtain cartoonish color palette Edit: Bilateral filtering should suit your needs even better Min filter (zeroth percentile) to enhance

What is the canonical way to determine commandline vs. http execution of a PHP script?

自古美人都是妖i 提交于 2019-11-26 12:07:17
I have a PHP script that needs to determine if it's been executed via the command-line or via HTTP, primarily for output-formatting purposes. What's the canonical way of doing this? I had thought it was to inspect SERVER['argc'] , but it turns out this is populated, even when using the 'Apache 2.0 Handler' server API. Use the php_sapi_name() function. if (php_sapi_name() == "cli") { // In cli-mode } else { // Not in cli-mode } Here are some relevant notes from the docs: php_sapi_name — Returns the type of interface between web server and PHP Although not exhaustive, the possible return values

Install WebExtensions on Firefox from the command line

陌路散爱 提交于 2019-11-26 11:27:51
问题 I found the question How to install Firefox addon from command line in scripts? that seems to work for Firefox extensions (i.e. ones with an install.rdf file) but what about WebExtensions (extension with a manifest.json file instead)? 回答1: Please see: Installing extensions Customizing Firefox: Including extensions with your distribution of Firefox The question you link on askubuntu: How to install Firefox addon from command line in scripts? is several years out of date, but does have some

Merge / convert multiple PDF files into one PDF

强颜欢笑 提交于 2019-11-26 10:56:18
How could I merge / convert multiple PDF files into one large PDF file? I tried the following, but the content of the target file was not as expected: convert file1.pdf file2.pdf merged.pdf I need a very simple/basic command line (CLI) solution. Best would be if I could pipe the output of the merge / convert straight into pdf2ps ( as originally attempted in my previously asked question here: Linux piping ( convert -> pdf2ps -> lp) ). Considering that pdfunite is part of poppler it has a higher chance to be installed, usage is also simpler than pdftk : pdfunite in-1.pdf in-2.pdf in-n.pdf out