vramsteg-1.0.1/AUTHORS000644 000765 000024 00000000555 12211206245 016055 0ustar00ultrafreddestaff000000 000000 The development of vramsteg was made possible by the significant contributions of the following people: Paul Beckingham (Author) Federico Hernandez (Author) The following submitted code, packages or analysis, and deserve special thanks: - Alejandro Garrido Mota Thanks to the following, who submitted detailed bug reports and excellent suggestions: - vramsteg-1.0.1/ChangeLog000644 000765 000024 00000000577 12211213122 016553 0ustar00ultrafreddestaff000000 000000 ------ current release --------------------------- 1.0.1 (2013-09-02) + Fixed compiler warnings. ------ old releases ------------------------------ 1.0.0 + Initial release supporting three bar styles, percentage, elapsed, remaining, labels and width settings. + When -width is not specified, uses the whole terminal width. Vramsteg project officially began 6th June, 2010. vramsteg-1.0.1/cmake.h000644 000765 000024 00000001076 12211206315 016233 0ustar00ultrafreddestaff000000 000000 /* cmake.h.in. Creates cmake.h during a build */ /* Package information */ #define PACKAGE "vramsteg" #define VERSION "1.0.1" #define PACKAGE_BUGREPORT "support@yootabory.com" #define PACKAGE_NAME "vramsteg" #define PACKAGE_TARNAME "vramsteg" #define PACKAGE_VERSION "1.0.1" #define PACKAGE_STRING "vramsteg 1.0.1" /* git information */ #define HAVE_COMMIT /* Compiling platform */ /* #undef LINUX */ #define DARWIN /* #undef CYGWIN */ /* #undef FREEBSD */ /* #undef OPENBSD */ /* #undef HAIKU */ /* #undef SOLARIS */ /* #undef WIN32 */ /* #undef UNKNOWN */ vramsteg-1.0.1/cmake.h.in000644 000765 000024 00000001157 12211206245 016642 0ustar00ultrafreddestaff000000 000000 /* cmake.h.in. Creates cmake.h during a build */ /* Package information */ #define PACKAGE "${PACKAGE}" #define VERSION "${VERSION}" #define PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" #define PACKAGE_NAME "${PACKAGE_NAME}" #define PACKAGE_TARNAME "${PACKAGE_TARNAME}" #define PACKAGE_VERSION "${PACKAGE_VERSION}" #define PACKAGE_STRING "${PACKAGE_STRING}" /* git information */ #cmakedefine HAVE_COMMIT /* Compiling platform */ #cmakedefine LINUX #cmakedefine DARWIN #cmakedefine CYGWIN #cmakedefine FREEBSD #cmakedefine OPENBSD #cmakedefine HAIKU #cmakedefine SOLARIS #cmakedefine WIN32 #cmakedefine UNKNOWN vramsteg-1.0.1/CMakeLists.txt000644 000765 000024 00000004450 12211206443 017543 0ustar00ultrafreddestaff000000 000000 cmake_minimum_required (VERSION 2.8) set (HAVE_CMAKE true) project (vramsteg) set (PROJECT_VERSION "1.0.1") SET (VRAMSTEG_MAN1DIR share/man/man1 CACHE STRING "Installation directory for man pages, section 1") SET (VRAMSTEG_DOCDIR share/doc/vramsteg CACHE STRING "Installation directory for doc files") if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set (LINUX true) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set (DARWIN true) elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set (FREEBSD true) elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") set (SOLARIS true) else (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set (UNKNOWN true) endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") message ("-- Looking for SHA1 references") if (EXISTS ${CMAKE_SOURCE_DIR}/.git/index) set (HAVE_COMMIT true) execute_process (COMMAND git log -1 --pretty=format:%h WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE COMMIT) configure_file ( ${CMAKE_SOURCE_DIR}/commit.h.in ${CMAKE_SOURCE_DIR}/commit.h) message ("-- Found SHA1 reference: ${COMMIT}") endif (EXISTS ${CMAKE_SOURCE_DIR}/.git/index) set (PACKAGE "${PROJECT_NAME}") set (VERSION "${PROJECT_VERSION}") set (PACKAGE_BUGREPORT "support@yootabory.com") set (PACKAGE_NAME "${PACKAGE}") set (PACKAGE_TARNAME "${PACKAGE}") set (PACKAGE_VERSION "${VERSION}") set (PACKAGE_STRING "${PACKAGE} ${VERSION}") message ("-- Configuring cmake.h") configure_file ( ${CMAKE_SOURCE_DIR}/cmake.h.in ${CMAKE_SOURCE_DIR}/cmake.h) add_subdirectory (src) add_subdirectory (doc) add_subdirectory (examples) if (EXISTS test) add_subdirectory (test EXCLUDE_FROM_ALL) endif (EXISTS test) set (doc_FILES NEWS ChangeLog README INSTALL AUTHORS COPYING) foreach (doc_FILE ${doc_FILES}) install (FILES ${doc_FILE} DESTINATION ${VRAMSTEG_DOCDIR}) endforeach (doc_FILE) # --- set (CPACK_SOURCE_GENERATOR "TGZ") set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION}) set (CPACK_SOURCE_IGNORE_FILES "CMakeCache" "CMakeFiles" "CPackConfig" "CPackSourceConfig" "_CPack_Packages" "cmake_install" "install_manifest" "Makefile$" "test" "demo" "src/vramsteg$" "/\\.gitignore" "/\\.git/" "swp$") include (CPack) vramsteg-1.0.1/commit.h000644 000765 000024 00000000147 12211206315 016441 0ustar00ultrafreddestaff000000 000000 /* commit.h.in. Creates commit.h during a cmake run */ /* git information */ #define COMMIT "ac58278" vramsteg-1.0.1/commit.h.in000644 000765 000024 00000000151 12211206245 017043 0ustar00ultrafreddestaff000000 000000 /* commit.h.in. Creates commit.h during a cmake run */ /* git information */ #define COMMIT "${COMMIT}" vramsteg-1.0.1/COPYING000644 000765 000024 00000002231 12211206245 016031 0ustar00ultrafreddestaff000000 000000 Vramsteg - a command line progress bar. Copyright 2010 - 2013, Paul Beckingham, Federico Hernandez. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://www.opensource.org/licenses/mit-license.php vramsteg-1.0.1/doc/CMakeLists.txt000644 000765 000024 00000000602 12211206245 020303 0ustar00ultrafreddestaff000000 000000 cmake_minimum_required (VERSION 2.8) message ("-- Configuring man pages") set (man_FILES vramsteg.1) foreach (man_FILE ${man_FILES}) configure_file ( man/${man_FILE}.in man/${man_FILE}) endforeach (man_FILE) install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/man/ DESTINATION ${VRAMSTEG_MAN1DIR} FILES_MATCHING PATTERN "*.1") vramsteg-1.0.1/doc/man/vramsteg.1000644 000765 000024 00000013567 12211206315 020244 0ustar00ultrafreddestaff000000 000000 .TH vramsteg 1 2013-09-02 "vramsteg 1.0.1" "User Manuals" .SH NAME vramsteg \- CLI progress bar .SH SYNOPSIS To display/update a progress bar: .B vramsteg --min --max --current [options] To remove a progress bar: .B vramsteg --remove To capture the start time: .B START=$(vramsteg --now) To include elapsed time (which requires a start time): .B vramsteg --start=$START --elapsed ... To include estimated remaining time (which requires a start time): .B vramsteg --start=$START --estimate ... To use a specific bar width: .B vramsteg --width 100 ... To show the percentage completed: .B vramsteg --percentage ... To show a label at the beginning of the bar: .B vramsteg --label "This is a label" ... To use an alternate rendering style: .B vramsteg --style ... .SH DESCRIPTION ('progress' in Swedish, almost) is an open source, command line utility that provides shell scripts with a full-featured progress indicator. The progress bar can display elapsed time, remaining time estimate, percentage completed, and labels. The progress bar can have user-specified colors, and be rendered in multiple styles. If you have a shell script, or in fact any command line program that needs a progress bar, vramsteg may be the right solution. Suppose you have a program that is performing a lengthy operation, provided that it has an opportunity to execute vramsteg frequently, then integrating a progress bar is simple. You may have seen progress bars used to good effect in the rsync or scp commands, among others. .SH EXAMPLES Here is a complete bash shell script illustrating how vramsteg works, in the simplest case: #! /bin/bash vramsteg \-\-min 0 \-\-max 4 \-\-current 0 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 1 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 2 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 3 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 4 echo Obviously this is a contrived example, but it illustrates how vramsteg is used to show a 4 step process. The \-\-min and \-\-max arguments specify what constitutes 0% and 100% of the work, and are integer values. The \-\-current argument represents where the progress bar is at any moment. The example takes 4 seconds to complete, but those sleep commands are proxies for whatever your program is doing. A more realistic example involves looping. Here is a simple shell script loop that will be used for a more complete example: #! /bin/bash for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i sleep 1 done echo Again, the sleep command represents the real work that is being done. Note that the 'echo' command at the end provides a newline character to prevent any text from overwriting the bar. To remove the bar when done, the script becomes: #! /bin/bash for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i sleep 1 done vramsteg \-\-remove Now the last list replaces the need for the 'echo' command. There are two features that require some additional code. In order to display the elapsed time, vramsteg needs to know the time when the process began. Because vramsteg is stateless, the start time needs to be specified on every call, but first the start time must be captured. There is a \-\-now option that causes the current time (in epoch form) to be displayed: vramsteg \-\-now 1276361315 This value needs to be captured by the shell script, like this: START=$(vramsteg \-\-now) or START=`vramsteg \-\-now` Then along with the \-\-elapsed option, the start time is provided to each call of vramsteg like this: #! /bin/bash START=$(../vramsteg \-\-now) for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i \-\-start $START \-\-elapsed sleep 1 done vramsteg \-\-remove Because vramsteg is stateless, which means it doesn't record any information on disk, the start time needs to be specified for every vramsteg call that makes use of it. The other feature is an estimate of the remaining time, which is used in a similar fashion: #! /bin/bash START=$(../vramsteg \-\-now) for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i \-\-start $START \-\-estimate sleep 1 done vramsteg \-\-remove The estimated time only displays whole numbers of seconds, and because the \-\-now option also only returns whole seconds, there can be inaccuracies in the elapsed and estimated time if process is fast. By default, vramsteg uses 80 columns to display the progress bar. You may override this by specifying a different width, but if you do, then you must also specify that width for all vramsteg calls, such as: vramsteg \-\-remove \-\-width 100 If you specify a width that is too small to include features like the label, percentage, elapsed and estimated time, an error is reported. If you enter the command: vramsteg without arguments, the command usage is displayed, including examples of progress bars in the supported styles. .SH FILES Vramsteg has no external dependencies, uses no files, and leaves no trace. It is, in fact, a completely stateless program, which is why there are required command line arguments for some features. .SH "CREDITS & COPYRIGHTS" Copyright (C) 2010 \- 2013 P. Beckingham, F. Hernandez Copyright (C) 2010 \- 2013 Göteborg Bit Factory .br Vramsteg is distributed under the MIT license. See http://www.opensource.org/licenses/mit-license.php for more information. .SH SEE ALSO For more information regarding vramsteg, the following may be referenced: .TP The official site at .TP The official code repository at .TP You can contact the project by writing an email to .SH REPORTING BUGS .TP Bugs in vramsteg may be reported to vramsteg-1.0.1/doc/man/vramsteg.1.in000644 000765 000024 00000013567 12211206245 020653 0ustar00ultrafreddestaff000000 000000 .TH vramsteg 1 2013-09-02 "vramsteg 1.0.1" "User Manuals" .SH NAME vramsteg \- CLI progress bar .SH SYNOPSIS To display/update a progress bar: .B vramsteg --min --max --current [options] To remove a progress bar: .B vramsteg --remove To capture the start time: .B START=$(vramsteg --now) To include elapsed time (which requires a start time): .B vramsteg --start=$START --elapsed ... To include estimated remaining time (which requires a start time): .B vramsteg --start=$START --estimate ... To use a specific bar width: .B vramsteg --width 100 ... To show the percentage completed: .B vramsteg --percentage ... To show a label at the beginning of the bar: .B vramsteg --label "This is a label" ... To use an alternate rendering style: .B vramsteg --style ... .SH DESCRIPTION ('progress' in Swedish, almost) is an open source, command line utility that provides shell scripts with a full-featured progress indicator. The progress bar can display elapsed time, remaining time estimate, percentage completed, and labels. The progress bar can have user-specified colors, and be rendered in multiple styles. If you have a shell script, or in fact any command line program that needs a progress bar, vramsteg may be the right solution. Suppose you have a program that is performing a lengthy operation, provided that it has an opportunity to execute vramsteg frequently, then integrating a progress bar is simple. You may have seen progress bars used to good effect in the rsync or scp commands, among others. .SH EXAMPLES Here is a complete bash shell script illustrating how vramsteg works, in the simplest case: #! /bin/bash vramsteg \-\-min 0 \-\-max 4 \-\-current 0 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 1 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 2 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 3 sleep 1 vramsteg \-\-min 0 \-\-max 4 \-\-current 4 echo Obviously this is a contrived example, but it illustrates how vramsteg is used to show a 4 step process. The \-\-min and \-\-max arguments specify what constitutes 0% and 100% of the work, and are integer values. The \-\-current argument represents where the progress bar is at any moment. The example takes 4 seconds to complete, but those sleep commands are proxies for whatever your program is doing. A more realistic example involves looping. Here is a simple shell script loop that will be used for a more complete example: #! /bin/bash for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i sleep 1 done echo Again, the sleep command represents the real work that is being done. Note that the 'echo' command at the end provides a newline character to prevent any text from overwriting the bar. To remove the bar when done, the script becomes: #! /bin/bash for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i sleep 1 done vramsteg \-\-remove Now the last list replaces the need for the 'echo' command. There are two features that require some additional code. In order to display the elapsed time, vramsteg needs to know the time when the process began. Because vramsteg is stateless, the start time needs to be specified on every call, but first the start time must be captured. There is a \-\-now option that causes the current time (in epoch form) to be displayed: vramsteg \-\-now 1276361315 This value needs to be captured by the shell script, like this: START=$(vramsteg \-\-now) or START=`vramsteg \-\-now` Then along with the \-\-elapsed option, the start time is provided to each call of vramsteg like this: #! /bin/bash START=$(../vramsteg \-\-now) for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i \-\-start $START \-\-elapsed sleep 1 done vramsteg \-\-remove Because vramsteg is stateless, which means it doesn't record any information on disk, the start time needs to be specified for every vramsteg call that makes use of it. The other feature is an estimate of the remaining time, which is used in a similar fashion: #! /bin/bash START=$(../vramsteg \-\-now) for i in {0..10} do vramsteg \-\-min 0 \-\-max 10 \-\-current $i \-\-start $START \-\-estimate sleep 1 done vramsteg \-\-remove The estimated time only displays whole numbers of seconds, and because the \-\-now option also only returns whole seconds, there can be inaccuracies in the elapsed and estimated time if process is fast. By default, vramsteg uses 80 columns to display the progress bar. You may override this by specifying a different width, but if you do, then you must also specify that width for all vramsteg calls, such as: vramsteg \-\-remove \-\-width 100 If you specify a width that is too small to include features like the label, percentage, elapsed and estimated time, an error is reported. If you enter the command: vramsteg without arguments, the command usage is displayed, including examples of progress bars in the supported styles. .SH FILES Vramsteg has no external dependencies, uses no files, and leaves no trace. It is, in fact, a completely stateless program, which is why there are required command line arguments for some features. .SH "CREDITS & COPYRIGHTS" Copyright (C) 2010 \- 2013 P. Beckingham, F. Hernandez Copyright (C) 2010 \- 2013 Göteborg Bit Factory .br Vramsteg is distributed under the MIT license. See http://www.opensource.org/licenses/mit-license.php for more information. .SH SEE ALSO For more information regarding vramsteg, the following may be referenced: .TP The official site at .TP The official code repository at .TP You can contact the project by writing an email to .SH REPORTING BUGS .TP Bugs in vramsteg may be reported to vramsteg-1.0.1/examples/all_default000755 000765 000024 00000000630 12211206245 021017 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo Default style echo Default colors echo With width echo With percentage echo With elapsed time echo With estimated remaining time echo With label echo With remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --width 80 --label label --min 0 --max 10 --current $i --percentage --elapsed --estimate --start $START sleep 1 done ../src/vramsteg --width 80 --remove vramsteg-1.0.1/examples/all_mono000755 000765 000024 00000000644 12211206245 020350 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'mono' style echo Default colors echo With width echo With percentage echo With elapsed time echo With estimated remaining time echo With label echo With remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --style mono --width 80 --label label --min 0 --max 10 --current $i --percentage --elapsed --estimate --start $START sleep 1 done ../src/vramsteg --width 80 --remove vramsteg-1.0.1/examples/all_text000755 000765 000024 00000000644 12211206245 020364 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'text' style echo Default colors echo With width echo With percentage echo With elapsed time echo With estimated remaining time echo With label echo With remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --style text --width 80 --label label --min 0 --max 10 --current $i --percentage --elapsed --estimate --start $START sleep 1 done ../src/vramsteg --width 80 --remove vramsteg-1.0.1/examples/basic_default000755 000765 000024 00000000410 12211206245 021324 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo Default style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo No label echo No remove for i in {0..10} do ../src/vramsteg --min 0 --max 10 --current $i sleep 1 done echo vramsteg-1.0.1/examples/basic_mono000755 000765 000024 00000000424 12211206245 020655 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'mono' style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo No label echo No remove for i in {0..10} do ../src/vramsteg --style mono --min 0 --max 10 --current $i sleep 1 done echo vramsteg-1.0.1/examples/basic_text000755 000765 000024 00000000424 12211206245 020671 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'text' style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo No label echo No remove for i in {0..10} do ../src/vramsteg --style text --min 0 --max 10 --current $i sleep 1 done echo vramsteg-1.0.1/examples/CMakeLists.txt000644 000765 000024 00000000713 12211207240 021353 0ustar00ultrafreddestaff000000 000000 cmake_minimum_required (VERSION 2.8) install (FILES all_default all_mono all_text basic_default basic_mono basic_text elapsed_default elapsed_mono elapsed_text estimate_default estimate_mono estimate_text label_default label_mono label_text minimal_default minimal_mono minimal_text percentage_default percentage_mono percentage_text remove_default remove_mono remove_text DESTINATION ${VRAMSTEG_DOCDIR}/examples) vramsteg-1.0.1/examples/elapsed_default000755 000765 000024 00000000502 12211206245 021662 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo Default style echo Default colors echo Default width echo No percentage echo With elapsed time echo No estimated remaining time echo No label echo No remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --min 0 --max 10 --current $i --elapsed --start $START sleep 1 done echo vramsteg-1.0.1/examples/elapsed_mono000755 000765 000024 00000000516 12211206245 021213 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'mono' style echo Default colors echo Default width echo No percentage echo With elapsed time echo No estimated remaining time echo No label echo No remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --style mono --min 0 --max 10 --current $i --elapsed --start $START sleep 1 done echo vramsteg-1.0.1/examples/elapsed_text000755 000765 000024 00000000516 12211206245 021227 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'text' style echo Default colors echo Default width echo No percentage echo With elapsed time echo No estimated remaining time echo No label echo No remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --style text --min 0 --max 10 --current $i --elapsed --start $START sleep 1 done echo vramsteg-1.0.1/examples/estimate_default000755 000765 000024 00000000503 12211206245 022061 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo Default style echo Default colors echo Default width echo No percentage echo No elapsed time echo With estimated remaining time echo No label echo No remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --min 0 --max 10 --current $i --estimate --start $START sleep 1 done echo vramsteg-1.0.1/examples/estimate_mono000755 000765 000024 00000000517 12211206245 021412 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'mono' style echo Default colors echo Default width echo No percentage echo No elapsed time echo With estimated remaining time echo No label echo No remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --style mono --min 0 --max 10 --current $i --estimate --start $START sleep 1 done echo vramsteg-1.0.1/examples/estimate_text000755 000765 000024 00000000517 12211206245 021426 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'text' style echo Default colors echo Default width echo No percentage echo No elapsed time echo With estimated remaining time echo No label echo No remove START=$(../src/vramsteg --now) for i in {0..10} do ../src/vramsteg --style text --min 0 --max 10 --current $i --estimate --start $START sleep 1 done echo vramsteg-1.0.1/examples/label_default000755 000765 000024 00000000436 12211206245 021332 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo Default style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo With label echo No remove for i in {0..10} do ../src/vramsteg --label "Bar label" --min 0 --max 10 --current $i sleep 1 done echo vramsteg-1.0.1/examples/label_mono000755 000765 000024 00000000452 12211206245 020654 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'mono' style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo With label echo No remove for i in {0..10} do ../src/vramsteg --style mono --label "Bar label" --min 0 --max 10 --current $i sleep 1 done echo vramsteg-1.0.1/examples/label_text000755 000765 000024 00000000452 12211206245 020670 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'text' style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo With label echo No remove for i in {0..10} do ../src/vramsteg --style text --label "Bar label" --min 0 --max 10 --current $i sleep 1 done echo vramsteg-1.0.1/examples/minimal_default000755 000765 000024 00000000375 12211206245 021703 0ustar00ultrafreddestaff000000 000000 #! /bin/bash ../src/vramsteg --min 0 --max 3 --current 0 sleep 1 ../src/vramsteg --min 0 --max 3 --current 1 sleep 1 ../src/vramsteg --min 0 --max 3 --current 2 sleep 1 ../src/vramsteg --min 0 --max 3 --current 3 sleep 1 ../src/vramsteg --remove echo vramsteg-1.0.1/examples/minimal_mono000755 000765 000024 00000000461 12211206245 021223 0ustar00ultrafreddestaff000000 000000 #! /bin/bash ../src/vramsteg --style mono --min 0 --max 3 --current 0 sleep 1 ../src/vramsteg --style mono --min 0 --max 3 --current 1 sleep 1 ../src/vramsteg --style mono --min 0 --max 3 --current 2 sleep 1 ../src/vramsteg --style mono --min 0 --max 3 --current 3 sleep 1 ../src/vramsteg --remove echo vramsteg-1.0.1/examples/minimal_text000755 000765 000024 00000000461 12211206245 021237 0ustar00ultrafreddestaff000000 000000 #! /bin/bash ../src/vramsteg --style text --min 0 --max 3 --current 0 sleep 1 ../src/vramsteg --style text --min 0 --max 3 --current 1 sleep 1 ../src/vramsteg --style text --min 0 --max 3 --current 2 sleep 1 ../src/vramsteg --style text --min 0 --max 3 --current 3 sleep 1 ../src/vramsteg --remove echo vramsteg-1.0.1/examples/percentage_default000755 000765 000024 00000000427 12211206245 022370 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo Default style echo Default colors echo Default width echo With percentage echo No elapsed time echo No estimated remaining time echo No label echo No remove for i in {0..10} do ../src/vramsteg --percentage --min=0 --max=10 --current=$i sleep 1 done echo vramsteg-1.0.1/examples/percentage_mono000755 000765 000024 00000000443 12211206245 021712 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'mono' style echo Default colors echo Default width echo With percentage echo No elapsed time echo No estimated remaining time echo No label echo No remove for i in {0..10} do ../src/vramsteg --style mono --percentage --min=0 --max=10 --current=$i sleep 1 done echo vramsteg-1.0.1/examples/percentage_text000755 000765 000024 00000000443 12211206245 021726 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'text' style echo Default colors echo Default width echo With percentage echo No elapsed time echo No estimated remaining time echo No label echo No remove for i in {0..10} do ../src/vramsteg --style text --percentage --min=0 --max=10 --current=$i sleep 1 done echo vramsteg-1.0.1/examples/remove_default000755 000765 000024 00000000437 12211206245 021551 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo Default style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo No label echo With remove for i in {0..10} do ../src/vramsteg --min=0 --max=10 --current=$i sleep 1 done ../src/vramsteg --remove vramsteg-1.0.1/examples/remove_mono000755 000765 000024 00000000453 12211206245 021073 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'mono' style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo No label echo With remove for i in {0..10} do ../src/vramsteg --style mono --min=0 --max=10 --current=$i sleep 1 done ../src/vramsteg --remove vramsteg-1.0.1/examples/remove_text000755 000765 000024 00000000453 12211206245 021107 0ustar00ultrafreddestaff000000 000000 #! /bin/bash echo 'text' style echo Default colors echo Default width echo No percentage echo No elapsed time echo No estimated remaining time echo No label echo With remove for i in {0..10} do ../src/vramsteg --style text --min=0 --max=10 --current=$i sleep 1 done ../src/vramsteg --remove vramsteg-1.0.1/INSTALL000644 000765 000024 00000003243 12211206245 016033 0ustar00ultrafreddestaff000000 000000 Installation Instructions ------------------------- Please follow the instructions below to build vramsteg with cmake. Pre-requisites -------------- You will need the CMake build system installed in order to build vramsteg from source. More information on cmake can be obtained at http://cmake.org Basic Installation ------------------ Briefly, these shell commands will unpack, build and install vramsteg: $ tar xzf vramsteg-X.Y.Z.tar.gz [1] $ cd vramsteg-X.Y.Z [2] $ cmake . [3] $ make [4] $ sudo make install [5] $ cd .. ; rm -r vramsteg-X.Y.Z [6] These commands are explained below: 1. Unpacks the source tarball. This creates the directory vramsteg-X.Y.Z, containing all the code. 2. Change directory to the root of the distribution. 3. Invokes CMake to scan for dependencies and machine-specific details, then generate the makefiles. This may take a minute. 4. Builds vramsteg. This may take a minute. 5. Installs the program, documentation and other data files. 6. Removes the temporary directory. Build and configurations options -------------------------------- You can customize the configuration run with cmake variables. This will modify the installation process: To change the installation directory you use the following configuration variable: $ cmake -DCMAKE_INSTALL_PREFIX= . cmake configuration variables are applied with the -D option and consist of a and a : $ cmake -D= . vramsteg-1.0.1/LICENSE000644 000765 000024 00000002230 12211206245 016002 0ustar00ultrafreddestaff000000 000000 Vramsteg - a command line progress bar Copyright 2010 - 2013, Paul Beckingham, Federico Hernandez. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://www.opensource.org/licenses/mit-license.php vramsteg-1.0.1/NEWS000644 000765 000024 00000001376 12211206245 015506 0ustar00ultrafreddestaff000000 000000 New Features in vramsteg 1.0.1 - Bar labels - Percentage - Elapsed time - Remaining time - Width setting - Three styles - default, mono and text New commands in taskwarrior 2.3.0 - New configuration options in taskwarrior 2.3.0 - Newly deprecated features in taskwarrior 2.3.0 - --- Please refer to the ChangeLog file for full details. --- Vramsteg has been built and tested on the following configurations: * OS X 10.8 Mountain Lion and 10.7 Lion * Debian 7.0 Wheezy (stable) and 6.0 Squeeze (oldstable) plus Sid (testing) --- While Vramsteg has undergone testing, bugs are sure to remain. If you encounter a bug, please send a message to: support@yootabory.com and check for updates at http://tasktools.org. Thank you. vramsteg-1.0.1/README000644 000765 000024 00000001062 12211206245 015657 0ustar00ultrafreddestaff000000 000000 Vramsteg ('progress' in Svenska, almost) Vramsteg is an open source, command line utility that provides shell scripts with a full-featured progress indicator. The progress bar can display elapsed time, remaining time estimate, percentage completed, and labels. The progress bar can have user-specified colors, and be rendered in multiple styles. See the man page (enter 'man vramsteg') for full details on how to use vramsteg or look in the srv/examples directory for several shell scripts that illustrate usage. Check for updates at http://tasktools.org. vramsteg-1.0.1/src/CMakeLists.txt000644 000765 000024 00000000601 12211206245 020324 0ustar00ultrafreddestaff000000 000000 cmake_minimum_required (VERSION 2.8) include_directories (${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}) set (vramsteg_SRCS vramsteg.cpp Progress.cpp Progress.h) add_executable (vramsteg ${vramsteg_SRCS}) install (TARGETS vramsteg DESTINATION bin) #set (CMAKE_BUILD_TYPE debug) #set (CMAKE_C_FLAGS_DEBUG "-g") #set (CMAKE_C_FLAGS_RELEASE "-O3") vramsteg-1.0.1/src/Progress.cpp000644 000765 000024 00000030363 12211206245 020104 0ustar00ultrafreddestaff000000 000000 //////////////////////////////////////////////////////////////////////////////// // Vramsteg - Utility for displaying progress bars in shell scripts. // // Copyright 2010 - 2013, Paul Beckingham, Federico Hernandez. // All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // http://www.opensource.org/licenses/mit-license.php // //////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include //////////////////////////////////////////////////////////////////////////////// Progress::Progress () : style ("") , label ("") , width (0) , minimum (0) , maximum (0) , current (-1) , percentage (true) , remove (true) , start (0) , estimate (false) , elapsed (false) { } //////////////////////////////////////////////////////////////////////////////// Progress::Progress (const std::string& l, int w, int n, int x, bool p /* = true */, bool r /* = true */) : style ("") , label (l) , width (w) , minimum (n) , maximum (x) , percentage (p) , remove (r) , start (0) , estimate (false) , elapsed (false) { current = -1; } //////////////////////////////////////////////////////////////////////////////// Progress::~Progress () { } //////////////////////////////////////////////////////////////////////////////// void Progress::setStyle (const std::string& value) { style = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::setLabel (const std::string& value) { label = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::setWidth (int value) { width = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::setMin (int value) { minimum = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::setMax (int value) { maximum = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::showPercentage (bool value) { percentage = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::removeAfter (bool value) { remove = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::setStart (time_t value) { start = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::showEstimate (bool value) { estimate = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::showElapsed (bool value) { elapsed = value; } //////////////////////////////////////////////////////////////////////////////// void Progress::update (int value) { if (isatty (fileno (stdout)) && current != value) { // Box the range. if (value < minimum) value = minimum; if (value > maximum) value = maximum; // Current value. current = value; // Capable of supporting multiple styles. if (style == "") renderStyleDefault (); else if (style == "mono") renderStyleMono (); else if (style == "text") renderStyleText (); else throw std::string ("Style '") + style + "' not supported."; } } //////////////////////////////////////////////////////////////////////////////// void Progress::done () { if (isatty (fileno (stdout))) { if (remove) std::cout << "\r" << std::setfill (' ') << std::setw (width) << ' '; std::cout << std::endl; } } //////////////////////////////////////////////////////////////////////////////// std::string Progress::formatTime (time_t t) { char buffer [128]; int days = t / 86400; int hours = (t % 86400) / 3600; int minutes = (t % 3600) / 60; int seconds = t % 60; if (days) snprintf (buffer, 128, "%dd %d:%02d:%02d", days, hours, minutes, seconds); else if (hours) snprintf (buffer, 128, "%d:%02d:%02d", hours, minutes, seconds); else snprintf (buffer, 128, "%02d:%02d", minutes, seconds); return std::string (buffer); } //////////////////////////////////////////////////////////////////////////////// // Default style looks like this: // // label GGGGGGGGRRRRRRRRRRRRRRRRR 34% 0:12 0:35 // // ^^^^^ Label string // ^^^^^^^^ Completed bar (in green) // ^^^^^^^^^^^^^^^^^ Incomplete bar (in red) // ^^^^ Percentage complete // ^^^^ Elapsed time // ^^^^ Remaining estimate void Progress::renderStyleDefault () { // Fraction completed. float fraction = (1.0 * (current - minimum)) / (maximum - minimum); // Elapsed time. time_t now = time (NULL); std::string elapsed_time; if (elapsed && start != 0) elapsed_time = formatTime (now - start); // Estimated remaining time. std::string estimate_time; if (estimate && start != 0) { if (fraction >= 1e-6) estimate_time = formatTime ((time_t) (int) (((now - start) * (1.0 - fraction)) / fraction)); else estimate_time = formatTime (0); } // Calculate bar width. int bar = width - (label.length () ? label.length () + 1 : 0) - (percentage ? 5 : 0) - (elapsed ? elapsed_time.length () + 1 : 0) - (estimate ? estimate_time.length () + 1 : 0); if (bar < 1) throw std::string ("The specified width is insufficient."); int visible = (int) (fraction * bar); // Render. if (label.length ()) std::cout << label << ' '; if (visible > 0) std::cout << "\033[42m" // Green << std::setfill (' ') << std::setw (visible) << ' '; if (bar - visible > 0) std::cout << "\033[41m" // Red << std::setfill (' ') << std::setw (bar - visible) << ' '; std::cout << "\033[0m"; if (percentage) std::cout << " " << std::setfill (' ') << std::setw (3) << (int) (fraction * 100) << "%"; if (elapsed && start != 0) std::cout << " " << elapsed_time; if (estimate && start != 0 && fraction > 0.2) std::cout << " " << estimate_time; std::cout << "\r" << std::flush; } //////////////////////////////////////////////////////////////////////////////// // Mono style looks like this: // // label WWWWWWWWBBBBBBBBBBBBBBBBB 34% 0:12 0:35 // // ^^^^^ Label string // ^^^^^^^^ Completed bar (in white) // ^^^^^^^^^^^^^^^^^ Incomplete bar (in black) // ^^^^ Percentage complete // ^^^^ Elapsed time // ^^^^ Remaining estimate void Progress::renderStyleMono () { // Fraction completed. float fraction = (1.0 * (current - minimum)) / (maximum - minimum); // Elapsed time. time_t now = time (NULL); std::string elapsed_time; if (elapsed && start != 0) elapsed_time = formatTime (now - start); // Estimated remaining time. std::string estimate_time; if (estimate && start != 0) { if (fraction >= 1e-6) estimate_time = formatTime ((time_t) (int) (((now - start) * (1.0 - fraction)) / fraction)); else estimate_time = formatTime (0); } // Calculate bar width. int bar = width - (label.length () ? label.length () + 1 : 0) - (percentage ? 5 : 0) - (elapsed ? elapsed_time.length () + 1 : 0) - (estimate ? estimate_time.length () + 1 : 0); if (bar < 1) throw std::string ("The specified width is insufficient."); int visible = (int) (fraction * bar); // Render. if (label.length ()) std::cout << label << ' '; if (visible > 0) std::cout << "\033[47m" // White << std::setfill (' ') << std::setw (visible) << ' '; if (bar - visible > 0) std::cout << "\033[40m" // Black << std::setfill (' ') << std::setw (bar - visible) << ' '; std::cout << "\033[0m"; if (percentage) std::cout << " " << std::setfill (' ') << std::setw (3) << (int) (fraction * 100) << "%"; if (elapsed && start != 0) std::cout << " " << elapsed_time; if (estimate && start != 0) std::cout << " " << estimate_time; std::cout << "\r" << std::flush; } //////////////////////////////////////////////////////////////////////////////// // Text style looks like this: // // label [******** ] 34% 0:12 0:35 // // ^^^^^ Label string // ^^^^^^^^ Completed bar // ^^^^^^^^^^^^^^^^^ Incomplete bar // ^^^^ Percentage complete // ^^^^ Elapsed time // ^^^^ Remaining estimate void Progress::renderStyleText () { // Fraction completed. float fraction = (1.0 * (current - minimum)) / (maximum - minimum); // Elapsed time. time_t now = time (NULL); std::string elapsed_time; if (elapsed && start != 0) elapsed_time = formatTime (now - start); // Estimated remaining time. std::string estimate_time; if (estimate && start != 0) { if (fraction >= 1e-6) estimate_time = formatTime ((time_t) (int) (((now - start) * (1.0 - fraction)) / fraction)); else estimate_time = formatTime (0); } // Calculate bar width. int bar = width - 2 // The [ and ] - (label.length () ? label.length () + 1 : 0) - (percentage ? 5 : 0) - (elapsed ? elapsed_time.length () + 1 : 0) - (estimate ? estimate_time.length () + 1 : 0); if (bar < 1) throw std::string ("The specified width is insufficient."); int visible = (int) (fraction * bar); // Render. if (label.length ()) std::cout << label << ' '; std::cout << '['; if (visible > 0) std::cout << std::setfill ('*') << std::setw (visible) << '*'; if (bar - visible > 0) std::cout << std::setfill (' ') << std::setw (bar - visible) << ' '; std::cout << ']'; if (percentage) std::cout << " " << std::setfill (' ') << std::setw (3) << (int) (fraction * 100) << "%"; if (elapsed && start != 0) std::cout << " " << elapsed_time; if (estimate && start != 0) std::cout << " " << estimate_time; std::cout << "\r" << std::flush; } //////////////////////////////////////////////////////////////////////////////// vramsteg-1.0.1/src/Progress.h000644 000765 000024 00000004553 12211206245 017553 0ustar00ultrafreddestaff000000 000000 //////////////////////////////////////////////////////////////////////////////// // Vramsteg - Utility for displaying progress bars in shell scripts. // // Copyright 2010 - 2013, Paul Beckingham, Federico Hernandez. // All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // http://www.opensource.org/licenses/mit-license.php // //////////////////////////////////////////////////////////////////////////////// #ifndef INCLUDED_PROGRESS #define INCLUDED_PROGRESS #include #include class Progress { public: Progress (); Progress (const std::string&, int, int, int, bool = true, bool = true); ~Progress (); void setStyle (const std::string&); void setLabel (const std::string&); void setWidth (int); void setMin (int); void setMax (int); void showPercentage (bool); void removeAfter (bool); void setStart (time_t); void showEstimate (bool); void showElapsed (bool); void update (int); void done (); private: std::string formatTime (time_t); void renderStyleDefault (); void renderStyleMono (); void renderStyleText (); private: std::string style; std::string label; int width; int minimum; int maximum; int current; bool percentage; bool remove; time_t start; bool estimate; bool elapsed; }; #endif //////////////////////////////////////////////////////////////////////////////// vramsteg-1.0.1/src/vramsteg.cpp000644 000765 000024 00000022444 12211206245 020131 0ustar00ultrafreddestaff000000 000000 //////////////////////////////////////////////////////////////////////////////// // Vramsteg - Utility for displaying progress bars in shell scripts. // // Copyright 2010 - 2013, Paul Beckingham, Federico Hernandez. // All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // http://www.opensource.org/licenses/mit-license.php // //////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include extern char *optarg; extern int optind; extern int optopt; extern int opterr; extern int optreset; //////////////////////////////////////////////////////////////////////////////// void showUsage () { std::cout << "\n" << "Usage: vramsteg [options]\n" << "\n" << " -y, --style Style of bar rendering\n" << " -l, --label Progress bar label\n" << " -m, --min Equivalent to 0%\n" << " -x, --max Equivalent to 100%\n" << " -c, --current Current value of progress bar\n" << " -p, --percentage Show percentage\n" << " -s, --start Start time epoch\n" << " -w, --width Width of progress bar, default full width\n" << " -n, --now Returns current time as epoch\n" << " -r, --remove Removes the progress bar\n" << " -e, --elapsed Show elapsed time (needs --start)\n" << " -t, --estimate Show estimated remaining time (needs --start)\n" #ifdef WAITING_FOR_VITAPI << " -d, --done Color of completed part\n" << " -a, --remaining Color of incomplete part\n" #endif << " -v, --version Show vramsteg version\n" << " -h, --help Show command options\n" << "\n" << "Supported styles are:\n" << " (default) label \033[42m \033[41m \033[0m 40%\n" << " mono label \033[47m \033[40m \033[0m 20%\n" << " text label [************ ] 60%\n" << std::endl; exit (0); } //////////////////////////////////////////////////////////////////////////////// void showVersion () { std::cout << "\n" << "\033[1m" << PACKAGE_STRING << "\033[0m\n" << "Copyright (C) 2010 - 2013, Göteborg Bit Factory\n" << "Copyright (C) 2010 - 2013, P. Beckingham, F. Hernandez.\n" << "\n" << "Vramsteg may be copied only under the terms of the MIT license, " << "which may be found in the taskwarrior source kit.\n" << "\n" << "Documentation for vramsteg can be found using 'man vramsteg', or " << "at http://tasktools.org.\n\n" << std::flush; exit (0); } //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { try { // We don't want any signals causing the program to quit in mid output, as // this would lead to odd colors persisting in the terminal. signal (SIGHUP, SIG_IGN); signal (SIGINT, SIG_IGN); signal (SIGKILL, SIG_IGN); signal (SIGPIPE, SIG_IGN); signal (SIGTERM, SIG_IGN); signal (SIGUSR1, SIG_IGN); signal (SIGUSR2, SIG_IGN); int arg_current = 0; #ifdef WAITING_FOR_VITAPI std::string arg_done = ""; #endif bool arg_elapsed = false; bool arg_estimate = false; std::string arg_label; int arg_max = 0; int arg_min = 0; bool arg_percentage = false; #ifdef WAITING_FOR_VITAPI std::string arg_remaining = ""; #endif bool arg_remove = false; time_t arg_start = 0; int arg_width = 80; std::string arg_style = ""; // Dynamically determine terminal width. unsigned short buff[4]; if (ioctl (fileno(stdout), TIOCGWINSZ, &buff) != -1) arg_width = buff[1]; static struct option longopts[] = { { "current", required_argument, NULL, 'c' }, #ifdef WAITING_FOR_VITAPI { "done", required_argument, NULL, 'd' }, #endif { "elapsed", no_argument, NULL, 'e' }, { "estimate", no_argument, NULL, 't' }, { "label", required_argument, NULL, 'l' }, { "max", required_argument, NULL, 'x' }, { "min", required_argument, NULL, 'm' }, { "now", no_argument, NULL, 'n' }, { "percentage", no_argument, NULL, 'p' }, #ifdef WAITING_FOR_VITAPI { "remaining", required_argument, NULL, 'a' }, #endif { "remove", no_argument, NULL, 'r' }, { "start", required_argument, NULL, 's' }, { "version", no_argument, NULL, 'v' }, { "width", required_argument, NULL, 'w' }, { "style", required_argument, NULL, 'y' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; int ch; #ifdef WAITING_FOR_VITAPI while ((ch = getopt_long (argc, argv, "c:d:etl:x:m:npa:rs:vw:h", longopts, NULL)) != -1) #else while ((ch = getopt_long (argc, argv, "c:etl:x:m:nprs:vw:h", longopts, NULL)) != -1) #endif { switch (ch) { case 'c': arg_current = atoi (optarg); break; #ifdef WAITING_FOR_VITAPI case 'd': arg_done = optarg; break; #endif case 'e': arg_elapsed = true; break; case 't': arg_estimate = true; break; case 'l': arg_label = optarg; break; case 'x': arg_max = atoi (optarg); break; case 'm': arg_min = atoi (optarg); break; case 'n': std::cout << time (NULL) << std::endl; exit (0); case 'p': arg_percentage = true; break; #ifdef WAITING_FOR_VITAPI case 'a': arg_remaining = optarg; break; #endif case 'r': arg_remove = true; break; case 's': arg_start = atoi (optarg); break; case 'v': showVersion (); break; case 'w': arg_width = atoi (optarg); break; case 'y': arg_style = optarg; break; case 'h': showUsage (); break; default: std::cout << "" << std::endl; break; } } argc -= optind; argv += optind; // Sanity check arguments. if (arg_min || arg_max) if (arg_min > arg_max) throw std::string ("The --max value must not be less than the --min value."); if (arg_min || arg_max || arg_current) if (arg_min > arg_current || arg_current > arg_max) throw std::string ("The --current value must not lie outside the --min/--max range."); if (arg_width && arg_label.length ()) if (arg_label.length () >= arg_width) throw std::string ("The --label string is longer than the allowed --width value."); if (! arg_remove && ! (arg_min || arg_current || arg_max)) showUsage (); if (arg_elapsed && arg_start == 0) throw std::string ("To use the --elapsed feature, --start must be provided."); if (arg_estimate && arg_start == 0) throw std::string ("To use the --estimate feature, --start must be provided."); // Disallow signals from stopping the program while it is displaying color codes // Set up and render Progress object. Progress p (arg_label, arg_width, arg_min, arg_max, arg_percentage, arg_remove); p.setStyle (arg_style); p.setStart (arg_start); p.showElapsed (arg_elapsed); p.showEstimate (arg_estimate); p.removeAfter (arg_remove); p.update (arg_current); if (arg_remove) p.done (); } catch (const std::string& e) { std::cerr << "Error: " << e << std::endl; } catch (...) { std::cerr << "Unknown error occurred - please report." << std::endl; } return 0; } ////////////////////////////////////////////////////////////////////////////////