Java에서 command line parameter parsing하기 IT 이야기/프로그래밍2010/07/07 12:14
Java에서 command line parameter들을 parsing 할때 (제가 잘 모르는 건지는 모르겠지만) 스마트한 방법이 없어 고생을 하고 있다가 맘먹고 구글링을 한 끝에 유용한 라이브러리를 알게 되어서 소개도하고 기록도 해 둘겸 글 남깁니다.
Apache에서 만든 Commons CLI인데요, 다음은 홈페이지에 나온 소개글을 발췌한 것입니다.
The Apache Commons CLI library provides an API for parsing command line options passed to programs. It's also able to print help messages detailing the options available for a command line tool. Commons CLI supports different types of options:tar -zxvf foo.tar.gz)du --human-readable --max-depth=1)java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo)gcc -O2 foo.c)ant -projecthelp)
특히, 아래와 같은 help message도 자동으로 만들어 주기 때문에 정말 편하게 사용할 수 있는 것 같습니다.
usage: ls
-A,--almost-all do not list implied . and ..
-a,--all do not hide entries starting with .
-B,--ignore-backups do not list implied entried ending with ~
-b,--escape print octal escapes for nongraphic characters
--block-size <SIZE> use SIZE-byte blocks
-c with -lt: sort by, and show, ctime (time of last
modification of file status information) with
-l:show ctime and sort by name otherwise: sort
by ctime
-C list entries by columns
홈페이지에 가면 소스코드 및 매뉴얼, 간단한 가이드까지 보실수 있습니다.
'IT 이야기 > 프로그래밍' 카테고리의 다른 글
| Java에서 command line parameter parsing하기 (2) | 2010/07/07 |
|---|---|
| Sudoku as an SMT problem (upgrade?) (6) | 2009/10/06 |
)가 보이도록 설정을 하였고, 본문 아래의 부가항목들에서는 보이지 않도록 만들어 보았습니다.
디렉토리 등록/변경 요건

댓글을 달아 주세요
이런 좋은 프로그램도 공짜로 만들어 주고. 참 고마운 사람이 많아.
그러게.. 세상엔 참 똑똑한 사람들이 많은 것 같오.