57 lines
2 KiB
Text
57 lines
2 KiB
Text
|
|
/*
|
||
|
|
Crafter® Build
|
||
|
|
Copyright (C) 2026 Catcrafts®
|
||
|
|
Catcrafts.net
|
||
|
|
|
||
|
|
This library is free software; you can redistribute it and/or
|
||
|
|
modify it under the terms of the GNU Lesser General Public
|
||
|
|
License version 3.0 as published by the Free Software Foundation;
|
||
|
|
|
||
|
|
This library is distributed in the hope that it will be useful,
|
||
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
|
Lesser General Public License for more details.
|
||
|
|
|
||
|
|
You should have received a copy of the GNU Lesser General Public
|
||
|
|
License along with this library; if not, write to the Free Software
|
||
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
|
|
*/
|
||
|
|
|
||
|
|
module;
|
||
|
|
#include "Crafter.Build-Api.h"
|
||
|
|
export module Crafter.Build:Progress;
|
||
|
|
import std;
|
||
|
|
|
||
|
|
export namespace Crafter::Progress {
|
||
|
|
enum class Verbosity { Quiet, Default, Verbose };
|
||
|
|
|
||
|
|
CRAFTER_API void SetVerbosity(Verbosity v);
|
||
|
|
CRAFTER_API Verbosity GetVerbosity();
|
||
|
|
|
||
|
|
// RAII work-unit marker. Construction inflates the running total; destruction
|
||
|
|
// increments completed and (on Default + TTY) redraws the status line. Move
|
||
|
|
// semantics are disabled — keep these as plain stack locals inside the worker
|
||
|
|
// lambda so the destructor fires when that thread's work ends.
|
||
|
|
class CRAFTER_API Task {
|
||
|
|
public:
|
||
|
|
explicit Task(std::string label);
|
||
|
|
~Task();
|
||
|
|
Task(const Task&) = delete;
|
||
|
|
Task& operator=(const Task&) = delete;
|
||
|
|
Task(Task&&) = delete;
|
||
|
|
Task& operator=(Task&&) = delete;
|
||
|
|
private:
|
||
|
|
std::string label_;
|
||
|
|
};
|
||
|
|
|
||
|
|
// Verbose-mode command echo. No-op outside Verbose.
|
||
|
|
CRAFTER_API void EchoCommand(std::string_view command);
|
||
|
|
|
||
|
|
// Erase the in-place status line so subsequent stderr writes (errors,
|
||
|
|
// banners) don't collide with it. No-op when not in TTY-redraw mode.
|
||
|
|
CRAFTER_API void Clear();
|
||
|
|
|
||
|
|
// Print "Built N targets in Xms" (or equivalent) and clear in-place state.
|
||
|
|
// Safe to call multiple times; subsequent calls are no-ops.
|
||
|
|
CRAFTER_API void Finalize();
|
||
|
|
}
|