-
-
Save konstin/1e7450131fb59c216256ec1367f394b5 to your computer and use it in GitHub Desktop.
indicatif crash
indicatif crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use indicatif::{ProgressBar, ProgressStyle}; | |
use rand::prelude::*; | |
use rand::Rng; | |
use std::{thread, time}; | |
const NAMES: &[&str] = &[ | |
"aiohttp", | |
"aiosignal", | |
"asgiref", | |
"async_timeout", | |
"attrs", | |
"awscli", | |
"azure_common", | |
"azure_core", | |
"azure_storage_blob", | |
"backports.zoneinfo", | |
"beautifulsoup4", | |
"boto3", | |
"botocore", | |
"cachetools", | |
"certifi", | |
"cffi", | |
"chardet", | |
"charset_normalizer", | |
"click", | |
"colorama", | |
"cryptography", | |
"cycler", | |
"decorator", | |
"Django", | |
"docker", | |
"docutils", | |
"filelock", | |
"Flask", | |
"fonttools", | |
"frozenlist", | |
"fsspec", | |
"gitdb", | |
"GitPython", | |
"google_api_core", | |
"google_api_python_client", | |
"google_auth", | |
"google_auth_httplib2", | |
"google_cloud_bigquery", | |
"google_cloud_core", | |
"google_cloud_storage", | |
"google_crc32c", | |
"google_resumable_media", | |
"googleapis_common_protos", | |
"greenlet", | |
"grpcio", | |
"grpcio_status", | |
"gunicorn", | |
"httplib2", | |
"idna", | |
"importlib_metadata", | |
"importlib_resources", | |
"iniconfig", | |
"isodate", | |
"itsdangerous", | |
"Jinja2", | |
"jmespath", | |
"joblib", | |
"jsonschema", | |
"kiwisolver", | |
"lxml", | |
"MarkupSafe", | |
"matplotlib", | |
"msrest", | |
"multidict", | |
"mypy_extensions", | |
"numpy", | |
"oauthlib", | |
"packaging", | |
"pandas", | |
"Pillow", | |
"platformdirs", | |
"plotly", | |
"pluggy", | |
"proto_plus", | |
"protobuf", | |
"psutil", | |
"py_spy", | |
"pyarrow", | |
"pyasn1", | |
"pyasn1_modules", | |
"pycparser", | |
"Pygments", | |
"PyJWT", | |
"pyOpenSSL", | |
"pyparsing", | |
"pyrsistent", | |
"pytest", | |
"python_dateutil", | |
"pytz", | |
"PyYAML", | |
"requests", | |
"requests_oauthlib", | |
"rsa", | |
"s3transfer", | |
"scipy", | |
"six", | |
"smmap", | |
"soupsieve", | |
"SQLAlchemy", | |
"sqlparse", | |
"tabulate", | |
"tenacity", | |
"toml", | |
"tqdm", | |
"typing_extensions", | |
"uritemplate", | |
"urllib3", | |
"websocket_client", | |
"Werkzeug", | |
"wrapt", | |
"yarl", | |
"zipp", | |
]; | |
fn main() { | |
let pb = ProgressBar::new(NAMES.len() as u64); | |
pb.set_style(ProgressStyle::default_bar().template("Installing {bar} {pos:>3}/{len:3} {msg}")); | |
let mut current = Vec::new(); | |
let mut todo = Vec::from(NAMES); | |
let name = todo.remove(0); | |
pb.println(name); | |
current.push(name); | |
while !current.is_empty() { | |
pb.set_message(format!("{:?}", current)); | |
if current.len() < 8 && !todo.is_empty() { | |
let name = todo.remove(0); | |
pb.println(name); | |
current.push(name); | |
} else { | |
current.remove(0); | |
pb.inc(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment