mirror of
https://github.com/NixOS/nix
synced 2025-06-26 15:51:15 +02:00
nix copy: Improve progress indicator
It now shows the amount of data copied: [8/1038 copied, 160.4/1590.9 MiB copied] copying path '...'
This commit is contained in:
parent
c5e4404580
commit
b29b6feaba
4 changed files with 111 additions and 38 deletions
|
@ -14,6 +14,7 @@ typedef enum {
|
|||
} Verbosity;
|
||||
|
||||
typedef enum {
|
||||
actUnknown = 0,
|
||||
actCopyPath = 100,
|
||||
} ActivityType;
|
||||
|
||||
|
@ -28,7 +29,8 @@ public:
|
|||
Activity(ActivityType type, std::string msg = "");
|
||||
~Activity();
|
||||
|
||||
//void progress(...);
|
||||
template<typename... Args>
|
||||
void progress(const Args & ... args);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
@ -49,6 +51,8 @@ typedef enum {
|
|||
|
||||
evStartActivity = 1000,
|
||||
evStopActivity = 1001,
|
||||
evProgress = 1002,
|
||||
evSetExpected = 1003,
|
||||
|
||||
} EventType;
|
||||
|
||||
|
@ -149,4 +153,14 @@ void warnOnce(bool & haveWarned, const FormatOrString & fs);
|
|||
|
||||
void writeToStderr(const string & s);
|
||||
|
||||
template<typename... Args>
|
||||
void Activity::progress(const Args & ... args)
|
||||
{
|
||||
Event ev;
|
||||
ev.type = evProgress;
|
||||
ev.fields.emplace_back(id);
|
||||
nop{(ev.fields.emplace_back(Event::Field(args)), 1)...};
|
||||
logger->event(ev);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue