Coder Social home page Coder Social logo

basemax / php-cli-apps Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 12 KB

A simple, fast, and fun example for building command line apps in PHP.

License: MIT License

PHP 100.00%
php cli-app cli command-line command-line-tool command-line-app command-line-interface command-line-parser command-line-tools command-line-arguments

php-cli-apps's Introduction

php-cli-apps

A simple, fast, and fun example for building command line apps in PHP.

Features

  • Support help text for special commands or in general
  • Support multi commands (also alias supported)
  • Support -h and --help flags
  • Support special flags for commands

max@base:~$ php cli.php

Usage:
  donya [command]

Available Commands:
  help        Help about any command
  install     Installing package(s) in DonyaOS
  remove      Removing package(s) in DonyaOS
  list        Listing package(s) in DonyaOS
  search      Search package(s) in the repository of DonyaOS

Flags:
  -h, --help   help for donya

Use "donya [command] --help" for more information about a command.

Sample Commands

php cli.php install php ; install php version 7.1
php cli.php i php ; install php version 7.1

php cli.php i php7.4 ; install php version 7.4
php cli.php i gcc ; install gcc

php cli.php s php ; search all package with php perfix
php cli.php search php ; search all package with php perfix

php cli.php r php ; remove php package
php cli.php remove php ; remove php package

php cli.php r php* ; remove all php prefix package

php cli.php i php* ; install all php prefix package

Getting start commands

function callCommand($command) {
	global $argv;
	$args=$argv;
	unset($args[0]); // software name. e.g: donya
	unset($args[1]); // command name
	$args=array_values($args); // start index of items from 0 in Array
	switch ($command) {
		case "i":
		case "install":
			commandInstall($args);
			break;
		case "r":
		case "remove":
			commandRemove($args);
			break;
		case "u":
		case "update":
			commandUpdate($args);
			break;
		case "l":
		case "list":
			commandList($args);
			break;
		case "s":
		case "search":
			commandSearch($args);
			break;
		case "h":
		case "help":
		default:
			help($command);
			break;
	}
}

Related Repositories

Donya Package Manager was purpose of building this command line app in PHP.


Max Base

My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers. (Max Base)

Asrez Team

A team includes some programmer, developer, designer, researcher(s) especially Max Base.

Asrez Team

php-cli-apps's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.